ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dma...@apache.org
Subject [3/4] ignite git commit: IGNITE-2947 BinaryContext doesn't honor custom loader set through IgniteConfiguration.classLoader
Date Wed, 04 May 2016 16:02:04 GMT
 IGNITE-2947 BinaryContext doesn't honor custom loader set through IgniteConfiguration.classLoader

# Conflicts:
#	modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java


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

Branch: refs/heads/ignite-2947
Commit: 7a219f5d36328f32e1f90e17762d273322a49809
Parents: 31feb85
Author: Anton Vinogradov <av@apache.org>
Authored: Fri Apr 8 10:32:13 2016 +0300
Committer: Denis Magda <dmagda@gridgain.com>
Committed: Wed May 4 16:46:55 2016 +0300

----------------------------------------------------------------------
 .../ignite/internal/binary/BinaryContext.java   |  75 ++++--
 .../binary/GridBinaryWildcardsSelfTest.java     |  65 +++--
 ...acheBinaryObjectUserClassloaderSelfTest.java | 240 +++++++++++++++++++
 .../IgniteBinaryObjectsTestSuite.java           |   3 +
 4 files changed, 331 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/7a219f5d/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
index 8754795..0a1ed11 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/BinaryContext.java
@@ -17,7 +17,6 @@
 
 package org.apache.ignite.internal.binary;
 
-import java.io.Externalizable;
 import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -39,6 +38,7 @@ import java.util.LinkedList;
 import java.util.Map;
 import java.util.Set;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.jar.JarEntry;
 import java.util.jar.JarFile;
@@ -99,8 +99,11 @@ import org.jsr166.ConcurrentHashMap8;
  * Binary context.
  */
 public class BinaryContext {
-    /** */
-    private static final ClassLoader dfltLdr = U.gridClassLoader();
+    /** System loader.*/
+    private static final ClassLoader sysLdr = U.gridClassLoader();
+
+    /** Reference to class loader set in IgniteConfiguration.classLoader */
+    private final ClassLoader cfgLdr;
 
     /** */
     private static final BinaryInternalMapper DFLT_MAPPER =
@@ -154,8 +157,9 @@ public class BinaryContext {
     /** */
     private final ConcurrentMap<Class<?>, BinaryClassDescriptor> descByCls =
new ConcurrentHashMap8<>();
 
-    /** Holds classes loaded by default class loader only. */
-    private final ConcurrentMap<Integer, BinaryClassDescriptor> userTypes = new ConcurrentHashMap8<>();
+    /** Cached types for system and configuration class loader. */
+    private final ConcurrentMap<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>>
cachedTypes =
+        new ConcurrentHashMap8<>();
 
     /** */
     private final Map<Integer, BinaryClassDescriptor> predefinedTypes = new HashMap<>();
@@ -203,13 +207,6 @@ public class BinaryContext {
     private volatile Map<Integer, BinarySchemaRegistry> schemas;
 
     /**
-     * For {@link Externalizable}.
-     */
-    public BinaryContext() {
-        // No-op.
-    }
-
-    /**
      * @param metaHnd Meta data handler.
      * @param igniteCfg Ignite configuration.
      * @param log Logger.
@@ -221,6 +218,7 @@ public class BinaryContext {
         this.metaHnd = metaHnd;
         this.igniteCfg = igniteCfg;
         this.log = log;
+        this.cfgLdr = igniteCfg.getClassLoader();
 
         colTypes.put(ArrayList.class, GridBinaryMarshaller.ARR_LIST);
         colTypes.put(LinkedList.class, GridBinaryMarshaller.LINKED_LIST);
@@ -597,12 +595,11 @@ public class BinaryContext {
             return desc;
 
         if (ldr == null)
-            ldr = dfltLdr;
+            ldr = sysLdr;
 
-        // If the type hasn't been loaded by default class loader then we mustn't return
the descriptor from here
-        // giving a chance to a custom class loader to reload type's class.
-        if (userType && ldr.equals(dfltLdr)) {
-            desc = userTypes.get(typeId);
+        // Classes re-loading is unsupported for both system and configuration loaders.
+        if (userType && (ldr.equals(sysLdr) || ldr.equals(cfgLdr))) {
+            desc = descriptor(typeId, ldr);
 
             if (desc != null)
                 return desc;
@@ -617,14 +614,14 @@ public class BinaryContext {
         }
         catch (ClassNotFoundException e) {
             // Class might have been loaded by default class loader.
-            if (userType && !ldr.equals(dfltLdr) && (desc = descriptorForTypeId(true,
typeId, dfltLdr, deserialize)) != null)
+            if (userType && !ldr.equals(sysLdr) && (desc = descriptorForTypeId(true,
typeId, sysLdr, deserialize)) != null)
                 return desc;
 
             throw new BinaryInvalidTypeException(e);
         }
         catch (IgniteCheckedException e) {
             // Class might have been loaded by default class loader.
-            if (userType && !ldr.equals(dfltLdr) && (desc = descriptorForTypeId(true,
typeId, dfltLdr, deserialize)) != null)
+            if (userType && !ldr.equals(sysLdr) && (desc = descriptorForTypeId(true,
typeId, sysLdr, deserialize)) != null)
                 return desc;
 
             throw new BinaryObjectException("Failed resolve class for ID: " + typeId, e);
@@ -727,10 +724,10 @@ public class BinaryContext {
                 new BinaryMetadata(typeId, typeName, desc.fieldsMeta(), affFieldName, schemas,
desc.isEnum()).wrap(this));
         }
 
-        // perform put() instead of putIfAbsent() because "registered" flag might have been
changed or class loader
-        // might have reloaded described class.
-        if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))
-            userTypes.put(typeId, desc);
+        ClassLoader ldr = IgniteUtils.detectClassLoader(cls);
+
+        if (ldr.equals(sysLdr) || ldr.equals(cfgLdr))
+            cacheDescriptor(typeId, desc, ldr);
 
         descByCls.put(cls, desc);
 
@@ -996,7 +993,7 @@ public class BinaryContext {
         Class<?> cls = null;
 
         try {
-            cls = Class.forName(clsName);
+            cls = U.resolveClassLoader(configuration()).loadClass(clsName);
         }
         catch (ClassNotFoundException | NoClassDefFoundError ignored) {
             // No-op.
@@ -1048,8 +1045,10 @@ public class BinaryContext {
             fieldsMeta = desc.fieldsMeta();
             schemas = desc.schema() != null ? Collections.singleton(desc.schema()) : null;
 
-            if (IgniteUtils.detectClassLoader(cls).equals(dfltLdr))
-                userTypes.put(id, desc);
+            ClassLoader ldr = IgniteUtils.detectClassLoader(cls);
+
+            if (ldr.equals(sysLdr) || ldr.equals(cfgLdr))
+                cacheDescriptor(id, desc, ldr);
 
             descByCls.put(cls, desc);
         }
@@ -1174,6 +1173,30 @@ public class BinaryContext {
         return optmMarsh;
     }
 
+    private BinaryClassDescriptor descriptor(int typeId, ClassLoader ldr) {
+        ConcurrentMap<Integer, BinaryClassDescriptor> map = cachedTypes.get(ldr);
+
+        if (map != null)
+            return map.get(typeId);
+
+        return null;
+    }
+
+    private void cacheDescriptor(int typeId, BinaryClassDescriptor dsc, ClassLoader ldr)
{
+        ConcurrentMap<Integer, BinaryClassDescriptor> ldrMap = cachedTypes.get(ldr);
+
+        if (ldrMap == null) {
+            ConcurrentMap<Integer, BinaryClassDescriptor> old = cachedTypes.putIfAbsent(ldr,
+                ldrMap = new ConcurrentHashMap<>());
+
+            if (old != null)
+                ldrMap = old;
+        }
+
+        // Don't use putIfAbsent because descriptor's "registered" flag might has been changed.
+        ldrMap.put(typeId, dsc);
+    }
+
     /**
      * Undeployment callback invoked when class loader is being undeployed.
      *

http://git-wip-us.apache.org/repos/asf/ignite/blob/7a219f5d/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
index d0d63b3..a424d13 100644
--- a/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
+++ b/modules/core/src/test/java/org/apache/ignite/internal/binary/GridBinaryWildcardsSelfTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.binary;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
 import org.apache.ignite.IgniteCheckedException;
 import org.apache.ignite.binary.BinaryBasicIdMapper;
 import org.apache.ignite.binary.BinaryIdMapper;
@@ -84,13 +85,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
-        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, mapper)));
-        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+        assertEquals(3, types.size());
+
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+        assertTrue(types.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, mapper)));
+        assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
     }
 
     /**
@@ -157,13 +160,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
+
+        assertEquals(3, types.size());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
-        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
-        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, idMapper)));
     }
 
     /**
@@ -346,13 +351,15 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
-        assertTrue(typeIds.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
-        assertTrue(typeIds.containsKey("type2".hashCode()));
+        assertEquals(3, types.size());
+
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, mapper)));
+        assertTrue(types.containsKey(typeId(INNER_CLASS_FULL_NAME, nameMapper, mapper)));
+        assertTrue(types.containsKey("type2".hashCode()));
 
         Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers
= U.field(ctx, "cls2Mappers");
 
@@ -387,12 +394,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
+
+        assertEquals(3, types.size());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
-        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
     }
 
     /**
@@ -460,12 +469,14 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
+
+        assertEquals(3, types.size());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
-        assertTrue(typeIds.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS2_FULL_NAME, nameMapper, idMapper)));
     }
 
     /**
@@ -580,11 +591,13 @@ public class GridBinaryWildcardsSelfTest extends GridCommonAbstractTest
{
 
         BinaryContext ctx = binaryContext(marsh);
 
-        Map<Integer, Class> typeIds = U.field(ctx, "userTypes");
+        Map<ClassLoader, ConcurrentMap<Integer, BinaryClassDescriptor>> ldrMap
= U.field(ctx, "cachedTypes");
 
-        assertEquals(3, typeIds.size());
+        ConcurrentMap<Integer, BinaryClassDescriptor> types = ldrMap.get(U.gridClassLoader());
+
+        assertEquals(3, types.size());
 
-        assertTrue(typeIds.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
+        assertTrue(types.containsKey(typeId(CLASS1_FULL_NAME, nameMapper, idMapper)));
 
         Map<String, org.apache.ignite.internal.binary.BinaryInternalMapper> typeMappers
= U.field(ctx, "cls2Mappers");
 

http://git-wip-us.apache.org/repos/asf/ignite/blob/7a219f5d/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
new file mode 100644
index 0000000..6dc2d71
--- /dev/null
+++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/binary/GridCacheBinaryObjectUserClassloaderSelfTest.java
@@ -0,0 +1,240 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF 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 License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache.binary;
+
+import java.io.Serializable;
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.binary.BinaryObjectException;
+import org.apache.ignite.binary.BinaryReader;
+import org.apache.ignite.binary.BinarySerializer;
+import org.apache.ignite.binary.BinaryTypeConfiguration;
+import org.apache.ignite.binary.BinaryWriter;
+import org.apache.ignite.configuration.BinaryConfiguration;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.binary.BinaryMarshaller;
+import org.apache.ignite.internal.util.typedef.internal.S;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.TcpDiscoveryIpFinder;
+import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+import static org.apache.ignite.cache.CacheWriteSynchronizationMode.FULL_SYNC;
+
+/**
+ *
+ */
+public class GridCacheBinaryObjectUserClassloaderSelfTest extends GridCommonAbstractTest
{
+    /** */
+    private static volatile boolean customBinaryConf = false;
+
+    /** */
+    private static volatile boolean deserialized = false;
+
+    /** */
+    private TcpDiscoveryIpFinder ipFinder = new TcpDiscoveryVmIpFinder(true);
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        stopAllGrids();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception
{
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        TcpDiscoverySpi disco = new TcpDiscoverySpi();
+
+        disco.setIpFinder(ipFinder);
+
+        cfg.setDiscoverySpi(disco);
+
+        cfg.setCacheConfiguration(cacheConfiguration(gridName));
+
+        cfg.setMarshaller(new BinaryMarshaller());
+
+        cfg.setClassLoader(getExternalClassLoader());
+
+        if (customBinaryConf) {
+            BinarySerializer bs = new BinarySerializer() {
+                /** {@inheritDoc} */
+                @Override public void writeBinary(Object obj, BinaryWriter writer) throws
BinaryObjectException {
+                    //No-op.
+                }
+
+                /** {@inheritDoc} */
+                @Override public void readBinary(Object obj, BinaryReader reader) throws
BinaryObjectException {
+                    deserialized = true;
+                }
+            };
+
+            BinaryTypeConfiguration btcfg1 = new BinaryTypeConfiguration();
+
+            btcfg1.setTypeName("org.apache.ignite.tests.p2p.CacheDeploymentTestValue");
+
+            btcfg1.setSerializer(bs);
+
+            BinaryTypeConfiguration btcfg2 = new BinaryTypeConfiguration();
+
+            btcfg2.setTypeName("org.apache.ignite.internal.processors.cache.binary." +
+                "GridCacheBinaryObjectUserClassloaderSelfTest$TestValue1");
+
+            btcfg2.setSerializer(bs);
+
+            BinaryConfiguration bcfg = new BinaryConfiguration();
+
+            Set<BinaryTypeConfiguration> set = new HashSet<>();
+
+            set.add(btcfg1);
+            set.add(btcfg2);
+
+            bcfg.setTypeConfigurations(set);
+
+            cfg.setBinaryConfiguration(bcfg);
+        }
+
+        return cfg;
+    }
+
+    /**
+     * Gets cache configuration for grid with specified name.
+     *
+     * @param gridName Grid name.
+     * @return Cache configuration.
+     */
+    CacheConfiguration cacheConfiguration(String gridName) {
+        CacheConfiguration cacheCfg = defaultCacheConfiguration();
+
+        cacheCfg.setCacheMode(REPLICATED);
+        cacheCfg.setWriteSynchronizationMode(FULL_SYNC);
+
+        return cacheCfg;
+    }
+
+    /**
+     * @throws Exception If test failed.
+     */
+    public void testConfigurationRegistration() throws Exception {
+        try {
+            customBinaryConf = true;
+
+            Ignite i1 = startGrid(1);
+            Ignite i2 = startGrid(2);
+
+            IgniteCache<Integer, Object> cache1 = i1.cache(null);
+            IgniteCache<Integer, Object> cache2 = i2.cache(null);
+
+            ClassLoader ldr = i1.configuration().getClassLoader();
+
+            Object v1 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestValue").newInstance();
+            Object v2 = ldr.loadClass("org.apache.ignite.tests.p2p.CacheDeploymentTestValue2").newInstance();
+
+            cache1.put(1, v1);
+            cache1.put(2, v2);
+            cache1.put(3, new TestValue1(123));
+            cache1.put(4, new TestValue2(123));
+
+            deserialized = false;
+
+            cache2.get(1);
+
+            assertTrue(deserialized);
+
+            deserialized = false;
+
+            cache2.get(2);
+
+            assertFalse(deserialized);
+
+            deserialized = false;
+
+            cache2.get(3);
+
+            assertTrue(deserialized);
+
+            deserialized = false;
+
+            cache2.get(4);
+
+            assertFalse(deserialized);
+        }
+        finally {
+            customBinaryConf = false;
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestValue1 implements Serializable {
+        /** */
+        private int val;
+
+        /**
+         * @param val Value.
+         */
+        public TestValue1(int val) {
+            this.val = val;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int value() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TestValue1.class, this);
+        }
+    }
+
+    /**
+     *
+     */
+    private static class TestValue2 implements Serializable {
+        /** */
+        private int val;
+
+        /**
+         * @param val Value.
+         */
+        public TestValue2(int val) {
+            this.val = val;
+        }
+
+        /**
+         * @return Value.
+         */
+        public int value() {
+            return val;
+        }
+
+        /** {@inheritDoc} */
+        @Override public String toString() {
+            return S.toString(TestValue2.class, this);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/7a219f5d/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
index 73c22e4..cedf9a7 100644
--- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
+++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteBinaryObjectsTestSuite.java
@@ -47,6 +47,7 @@ import org.apache.ignite.internal.binary.noncompact.BinaryObjectBuilderNonCompac
 import org.apache.ignite.internal.binary.streams.BinaryHeapStreamByteOrderSelfTest;
 import org.apache.ignite.internal.binary.streams.BinaryOffheapStreamByteOrderSelfTest;
 import org.apache.ignite.internal.processors.cache.BinaryObjectOffHeapUnswapTemporaryTest;
+import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryObjectUserClassloaderSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesDefaultMappersSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreBinariesSimpleNameMappersSelfTest;
 import org.apache.ignite.internal.processors.cache.binary.GridCacheBinaryStoreObjectsSelfTest;
@@ -140,6 +141,8 @@ public class IgniteBinaryObjectsTestSuite extends TestSuite {
         suite.addTestSuite(BinaryHeapStreamByteOrderSelfTest.class);
         suite.addTestSuite(BinaryOffheapStreamByteOrderSelfTest.class);
 
+        suite.addTestSuite(GridCacheBinaryObjectUserClassloaderSelfTest.class);
+
         return suite;
     }
 }


Mime
View raw message