killbill-memoizeit

payment: remove dependency on Ehcache CacheException doesn't

3/21/2017 8:03:19 AM

Details

payment/pom.xml 4(+0 -4)

diff --git a/payment/pom.xml b/payment/pom.xml
index 0fc7d88..3f3e881 100644
--- a/payment/pom.xml
+++ b/payment/pom.xml
@@ -97,10 +97,6 @@
             <scope>test</scope>
         </dependency>
         <dependency>
-            <groupId>net.sf.ehcache</groupId>
-            <artifactId>ehcache</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.shiro</groupId>
             <artifactId>shiro-core</artifactId>
         </dependency>
diff --git a/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCache.java b/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCache.java
index 9960e7a..cb2383a 100644
--- a/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCache.java
+++ b/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCache.java
@@ -1,6 +1,6 @@
 /*
- * Copyright 2016 Groupon, Inc
- * Copyright 2016 The Billing Project, LLC
+ * Copyright 2016-2017 Groupon, Inc
+ * Copyright 2016-2017 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -38,7 +38,6 @@ import org.testng.annotations.Test;
 
 import com.google.common.io.ByteStreams;
 import com.google.common.io.Resources;
-import net.sf.ehcache.CacheException;
 
 public class TestStateMachineConfigCache extends PaymentTestSuiteNoDB {
 
@@ -82,7 +81,7 @@ public class TestStateMachineConfigCache extends PaymentTestSuiteNoDB {
             @Override
             public String answer(final InvocationOnMock invocation) throws Throwable {
                 if (shouldThrow.get()) {
-                    throw new RuntimeException();
+                    throw new RuntimeException("For test purposes");
                 }
                 final InternalTenantContext internalContext = (InternalTenantContext) invocation.getArguments()[1];
                 if (multiTenantRecordId.equals(internalContext.getTenantRecordId())) {
@@ -141,8 +140,9 @@ public class TestStateMachineConfigCache extends PaymentTestSuiteNoDB {
         try {
             stateMachineConfigCache.getPaymentStateMachineConfig(pluginName, multiTenantContext);
             Assert.fail();
-        } catch (final CacheException exception) {
+        } catch (final RuntimeException exception) {
             Assert.assertTrue(exception.getCause() instanceof RuntimeException);
+            Assert.assertEquals(exception.getCause().getMessage(), "For test purposes");
         }
     }
 }
diff --git a/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCacheInvalidationCallback.java b/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCacheInvalidationCallback.java
index 9ead7cd..18b1f31 100644
--- a/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCacheInvalidationCallback.java
+++ b/payment/src/test/java/org/killbill/billing/payment/caching/TestStateMachineConfigCacheInvalidationCallback.java
@@ -1,6 +1,6 @@
 /*
- * Copyright 2016 Groupon, Inc
- * Copyright 2016 The Billing Project, LLC
+ * Copyright 2016-2017 Groupon, Inc
+ * Copyright 2016-2017 The Billing Project, LLC
  *
  * The Billing Project licenses this file to you under the Apache License, version 2.0
  * (the "License"); you may not use this file except in compliance with the
@@ -32,8 +32,6 @@ import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
-import net.sf.ehcache.CacheException;
-
 public class TestStateMachineConfigCacheInvalidationCallback extends PaymentTestSuiteNoDB {
 
     private InternalTenantContext multiTenantContext;
@@ -67,7 +65,7 @@ public class TestStateMachineConfigCacheInvalidationCallback extends PaymentTest
             @Override
             public String answer(final InvocationOnMock invocation) throws Throwable {
                 if (shouldThrow.get()) {
-                    throw new RuntimeException();
+                    throw new RuntimeException("For test purposes");
                 }
                 return null;
             }
@@ -87,8 +85,9 @@ public class TestStateMachineConfigCacheInvalidationCallback extends PaymentTest
         try {
             stateMachineConfigCache.getPaymentStateMachineConfig(pluginName, multiTenantContext);
             Assert.fail();
-        } catch (final CacheException exception) {
+        } catch (final RuntimeException exception) {
             Assert.assertTrue(exception.getCause() instanceof RuntimeException);
+            Assert.assertEquals(exception.getCause().getMessage(), "For test purposes");
         }
 
         // No exception (cached)
diff --git a/util/src/main/java/org/killbill/billing/util/cache/EhCacheBasedCacheController.java b/util/src/main/java/org/killbill/billing/util/cache/EhCacheBasedCacheController.java
index 27d2326..6372e3b 100644
--- a/util/src/main/java/org/killbill/billing/util/cache/EhCacheBasedCacheController.java
+++ b/util/src/main/java/org/killbill/billing/util/cache/EhCacheBasedCacheController.java
@@ -27,7 +27,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Function;
-import net.sf.ehcache.CacheException;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
 
@@ -130,8 +129,8 @@ public class EhCacheBasedCacheController<K, V> implements CacheController<K, V> 
         try {
             value = baseCacheLoader.compute(key, cacheLoaderArgument);
         } catch (final Exception e) {
-            logger.warn("Unable to compute cached value for key='{}' and cacheLoaderArgument='{}'", key, cacheLoaderArgument);
-            throw new CacheException(e);
+            logger.warn("Unable to compute cached value for key='{}' and cacheLoaderArgument='{}'", key, cacheLoaderArgument, e);
+            throw new RuntimeException(e);
         }
 
         if (value == null) {