ignite-321 review
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/6d15f90f Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/6d15f90f Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/6d15f90f Branch: refs/heads/ignite-264 Commit: 6d15f90f4be98632eaefdd87c9a379e5e062d27c Parents: 9a69903 Author: Yakov Zhdanov <yzhda...@gridgain.com> Authored: Wed Feb 25 21:12:20 2015 +0300 Committer: Yakov Zhdanov <yzhda...@gridgain.com> Committed: Wed Feb 25 21:12:20 2015 +0300 ---------------------------------------------------------------------- .../processors/cache/GridCacheUtils.java | 4 ++ .../IgniteCacheLoaderWriterAbstractTest.java | 47 ++++++++++++++++++++ 2 files changed, 51 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6d15f90f/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java index 7cd13df..1e67907 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheUtils.java @@ -39,6 +39,7 @@ import org.jetbrains.annotations.*; import javax.cache.*; import javax.cache.expiry.*; +import javax.cache.integration.*; import java.io.*; import java.util.*; import java.util.concurrent.*; @@ -1783,6 +1784,9 @@ public class GridCacheUtils { * @return CacheException runtime exception, never null. */ @NotNull public static CacheException convertToCacheException(IgniteCheckedException e) { + if (e.hasCause(CacheWriterException.class)) + return new CacheWriterException(e); + if (e instanceof CachePartialUpdateCheckedException) return new CachePartialUpdateException((CachePartialUpdateCheckedException)e); else if (e instanceof CacheAtomicUpdateTimeoutCheckedException) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/6d15f90f/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java index 4477f32..aa4199e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheLoaderWriterAbstractTest.java @@ -43,6 +43,9 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs /** */ private static ConcurrentHashMap8<Object, Object> storeMap = new ConcurrentHashMap8<>(); + /** */ + private static Set<Object> unaccessableKeys = new HashSet<>(); + /** {@inheritDoc} */ @Override protected Factory<? extends CacheLoader> loaderFactory() { return new Factory<CacheLoader>() { @@ -70,6 +73,8 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs writerCallCnt.set(0); storeMap.clear(); + + unaccessableKeys.clear(); } /** @@ -144,6 +149,42 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs } /** + * + */ + public void testLoaderException() { + IgniteCache<Object, Object> cache = jcache(0); + + unaccessableKeys.add(1); + + try { + cache.get(1); + + assert false : "Exception should be thrown"; + } + catch (CacheLoaderException ignored) { + // No-op. + } + } + + /** + * + */ + public void testWriterException() { + IgniteCache<Object, Object> cache = jcache(0); + + unaccessableKeys.add(1); + + try { + cache.put(1, 1); + + assert false : "Exception should be thrown"; + } + catch (CacheWriterException ignored) { + // No-op. + } + } + + /** * @throws Exception If failed. */ public void testLoaderWriterBulk() throws Exception { @@ -253,6 +294,9 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs ldrCallCnt.incrementAndGet(); + if (unaccessableKeys.contains(key)) + throw new CacheLoaderException(); + return storeMap.get(key); } @@ -304,6 +348,9 @@ public abstract class IgniteCacheLoaderWriterAbstractTest extends IgniteCacheAbs /** {@inheritDoc} */ @Override public void write(Cache.Entry<? extends Integer, ? extends Integer> e) { + if (unaccessableKeys.contains(e.getKey())) + throw new CacheWriterException(); + assertTrue(startCalled); assertNotNull(ignite);