# ignite-668

Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/682bec6a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/682bec6a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/682bec6a

Branch: refs/heads/ignite-639
Commit: 682bec6a5d2df9e91521622c82dd867a58f73be2
Parents: f9af2d5
Author: sboikov <sboi...@gridgain.com>
Authored: Fri Apr 3 14:53:53 2015 +0300
Committer: sboikov <sboi...@gridgain.com>
Committed: Fri Apr 3 14:53:53 2015 +0300

----------------------------------------------------------------------
 .../processors/cache/GridCacheProcessor.java    | 10 +++----
 .../cache/IgniteInternalCacheTypesTest.java     | 29 +++++++++++++++++++-
 .../processors/igfs/IgfsStartCacheTest.java     | 20 +++++++++++++-
 3 files changed, 52 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/682bec6a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
index 1d04fd2..0455ff0 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java
@@ -2302,15 +2302,15 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
             IgniteCache<K,V> cache = (IgniteCache<K, 
V>)jCacheProxies.get(masked);
 
-            if (cache == null) {
-                DynamicCacheDescriptor desc = registeredCaches.get(masked);
+            DynamicCacheDescriptor desc = registeredCaches.get(masked);
+
+            if (desc != null && !desc.cacheType().userCache())
+                throw new IllegalStateException("Failed to get cache because 
it is a system cache: " + cacheName);
 
+            if (cache == null) {
                 if (desc == null || desc.cancelled())
                     throw new IllegalArgumentException("Cache is not started: 
" + cacheName);
 
-                if (!desc.cacheType().userCache())
-                    throw new IllegalStateException("Failed to get cache 
because it is a system cache: " + cacheName);
-
                 DynamicCacheChangeRequest req = new 
DynamicCacheChangeRequest(cacheName, ctx.localNodeId());
 
                 req.cacheName(cacheName);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/682bec6a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
index 37bde6c..c9da7c5 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteInternalCacheTypesTest.java
@@ -25,8 +25,11 @@ import org.apache.ignite.internal.util.typedef.internal.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 import org.apache.ignite.testframework.junits.common.*;
 
+import java.util.concurrent.*;
+
 import static org.apache.ignite.internal.managers.communication.GridIoPolicy.*;
 
 /**
@@ -98,7 +101,31 @@ public class IgniteInternalCacheTypesTest extends 
GridCommonAbstractTest {
      * @param ignite Ignite.
      * @param userCaches User caches.
      */
-    private void checkCacheTypes(Ignite ignite, String... userCaches) {
+    private void checkCacheTypes(final Ignite ignite, String... userCaches) {
+        GridTestUtils.assertThrows(log(), new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ignite.cache(CU.UTILITY_CACHE_NAME);
+
+                return null;
+            }
+        }, IllegalStateException.class, null);
+
+        GridTestUtils.assertThrows(log(), new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ignite.cache(CU.MARSH_CACHE_NAME);
+
+                return null;
+            }
+        }, IllegalStateException.class, null);
+
+        GridTestUtils.assertThrows(log(), new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ignite.cache(CU.ATOMICS_CACHE_NAME);
+
+                return null;
+            }
+        }, IllegalStateException.class, null);
+
         checkCache(ignite, CU.UTILITY_CACHE_NAME, UTILITY_CACHE_POOL, false, 
true);
 
         checkCache(ignite, CU.MARSH_CACHE_NAME, MARSH_CACHE_POOL, false, 
false);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/682bec6a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
index 09fa455..b5162e2 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/igfs/IgfsStartCacheTest.java
@@ -26,8 +26,10 @@ import org.apache.ignite.internal.util.typedef.*;
 import org.apache.ignite.spi.discovery.tcp.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.*;
 import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*;
+import org.apache.ignite.testframework.*;
 
 import java.io.*;
+import java.util.concurrent.*;
 
 import static org.apache.ignite.cache.CacheAtomicityMode.*;
 import static org.apache.ignite.cache.CacheMode.*;
@@ -123,7 +125,23 @@ public class IgfsStartCacheTest extends 
IgfsCommonAbstractTest {
     /**
      * @param ignite Ignite.
      */
-    private void checkIgfsCaches(Ignite ignite) {
+    private void checkIgfsCaches(final Ignite ignite) {
+        GridTestUtils.assertThrows(log(), new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ignite.cache("dataCache");
+
+                return null;
+            }
+        }, IllegalStateException.class, null);
+
+        GridTestUtils.assertThrows(log(), new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                ignite.cache("metaCache");
+
+                return null;
+            }
+        }, IllegalStateException.class, null);
+
         checkCache(((IgniteKernal)ignite).internalCache("dataCache"));
         checkCache(((IgniteKernal)ignite).internalCache("metaCache"));
     }

Reply via email to