# Minor fix to cache object processor.

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

Branch: refs/heads/ignite-30
Commit: 7eef373aa8ba17561c9d89dfbc6c0af8bbc23ec9
Parents: 71439bc
Author: vozerov-gridgain <voze...@gridgain.com>
Authored: Wed Apr 8 17:54:56 2015 +0300
Committer: vozerov-gridgain <voze...@gridgain.com>
Committed: Wed Apr 8 17:55:49 2015 +0300

----------------------------------------------------------------------
 .../java/org/apache/ignite/internal/IgniteKernal.java    | 11 ++++++++++-
 .../internal/processors/cache/GridCacheProcessor.java    | 11 ++++++-----
 2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7eef373a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java 
b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
index 88bec0f..768bbd3 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgniteKernal.java
@@ -2240,10 +2240,19 @@ public class IgniteKernal implements IgniteEx, 
IgniteMXBean, Externalizable {
 
     /** {@inheritDoc} */
     @Override public <K, V> IgniteCache<K, V> cache(@Nullable String name) {
+        return cache(name, true);
+    }
+
+    /**
+     * @param name Cache name.
+     * @param failIfSys Fail if requestsed cache is system cache.
+     * @return Cache.
+     */
+    public <K, V> IgniteCache<K, V> cache(@Nullable String name, boolean 
failIfSys) {
         guard();
 
         try {
-            return ctx.cache().publicJCache(name);
+            return ctx.cache().publicJCache(name, true, failIfSys);
         }
         catch (IgniteCheckedException e) {
             throw CU.convertToCacheException(e);

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7eef373a/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 fcf65b9..35cfd0c 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
@@ -1713,7 +1713,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
      */
     public IgniteInternalFuture<?> dynamicStartCache(String cacheName) {
         try {
-            if (publicJCache(cacheName, false) != null) // Cache with given 
name already started.
+            if (publicJCache(cacheName, false, true) != null) // Cache with 
given name already started.
                 return new GridFinishedFuture<>();
 
             CacheConfiguration cfgTemplate = null;
@@ -2483,21 +2483,22 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
      * @throws IgniteCheckedException If failed.
      */
     public <K, V> IgniteCache<K, V> publicJCache(@Nullable String cacheName) 
throws IgniteCheckedException {
-        return publicJCache(cacheName, true);
+        return publicJCache(cacheName, true, true);
     }
 
     /**
      * @param cacheName Cache name.
      * @param failIfNotStarted If {@code true} throws {@link 
IllegalArgumentException} if cache is not started,
      *        otherwise returns {@code null} in this case.
+     * @param failIfSys Fail is cache is system.
      * @param <K> type of keys.
      * @param <V> type of values.
      * @return Cache instance for given name.
      * @throws IgniteCheckedException If failed.
      */
     @SuppressWarnings("unchecked")
-    @Nullable private <K, V> IgniteCache<K, V> publicJCache(@Nullable String 
cacheName, boolean failIfNotStarted)
-        throws IgniteCheckedException
+    @Nullable public <K, V> IgniteCache<K, V> publicJCache(@Nullable String 
cacheName, boolean failIfNotStarted,
+        boolean failIfSys) throws IgniteCheckedException
     {
         if (log.isDebugEnabled())
             log.debug("Getting public cache for name: " + cacheName);
@@ -2508,7 +2509,7 @@ public class GridCacheProcessor extends 
GridProcessorAdapter {
 
         DynamicCacheDescriptor desc = registeredCaches.get(masked);
 
-        if (desc != null && !desc.cacheType().userCache())
+        if (desc != null && !desc.cacheType().userCache() && failIfSys)
             throw new IllegalStateException("Failed to get cache because it is 
a system cache: " + cacheName);
 
         if (cache == null) {

Reply via email to