You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2015/09/22 21:54:32 UTC
ignite git commit: ignite-1272: full fix for classes reloading when
custom class loader and portable marshaller is used
Repository: ignite
Updated Branches:
refs/heads/ignite-1272 bce4ec1b8 -> 3fa7e4f77
ignite-1272: full fix for classes reloading when custom class loader and portable marshaller is used
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/3fa7e4f7
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/3fa7e4f7
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/3fa7e4f7
Branch: refs/heads/ignite-1272
Commit: 3fa7e4f77f7944081bb97857b6fb7776aec2cc13
Parents: bce4ec1
Author: Denis Magda <dm...@gridgain.com>
Authored: Tue Sep 22 22:54:20 2015 +0300
Committer: Denis Magda <dm...@gridgain.com>
Committed: Tue Sep 22 22:54:20 2015 +0300
----------------------------------------------------------------------
.../internal/portable/PortableContext.java | 45 +++++++++++---------
1 file changed, 25 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/3fa7e4f7/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
index ceb05a6..1c2cba2 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/PortableContext.java
@@ -52,24 +52,25 @@ import java.util.jar.JarFile;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.internal.IgniteKernal;
import org.apache.ignite.internal.IgnitionEx;
+import org.apache.ignite.internal.portable.api.PortableException;
+import org.apache.ignite.internal.portable.api.PortableIdMapper;
+import org.apache.ignite.internal.portable.api.PortableInvalidClassException;
+import org.apache.ignite.internal.portable.api.PortableMarshaller;
+import org.apache.ignite.internal.portable.api.PortableMetadata;
+import org.apache.ignite.internal.portable.api.PortableSerializer;
+import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
import org.apache.ignite.internal.processors.cache.portable.CacheObjectPortableProcessorImpl;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration;
+import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration;
import org.apache.ignite.internal.util.GridConcurrentHashSet;
+import org.apache.ignite.internal.util.IgniteUtils;
import org.apache.ignite.internal.util.lang.GridMapEntry;
import org.apache.ignite.internal.util.typedef.T2;
import org.apache.ignite.internal.util.typedef.internal.U;
import org.apache.ignite.lang.IgniteBiTuple;
import org.apache.ignite.marshaller.MarshallerContext;
import org.apache.ignite.marshaller.optimized.OptimizedMarshaller;
-import org.apache.ignite.internal.portable.api.PortableMarshaller;
-import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetConfiguration;
-import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableConfiguration;
-import org.apache.ignite.internal.processors.platform.dotnet.PlatformDotNetPortableTypeConfiguration;
-import org.apache.ignite.internal.portable.api.PortableException;
-import org.apache.ignite.internal.portable.api.PortableIdMapper;
-import org.apache.ignite.internal.portable.api.PortableInvalidClassException;
-import org.apache.ignite.internal.portable.api.PortableMetadata;
-import org.apache.ignite.internal.portable.api.PortableSerializer;
-import org.apache.ignite.internal.portable.api.PortableTypeConfiguration;
import org.jetbrains.annotations.Nullable;
import org.jsr166.ConcurrentHashMap8;
@@ -460,6 +461,18 @@ public class PortableContext implements Externalizable {
if (desc != null)
return desc;
+ if (ldr == null)
+ ldr = IgniteUtils.gridClassLoader();
+
+ if (userType) {
+ desc = userTypes.get(typeId);
+
+ // 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 (desc != null && ldr == IgniteUtils.gridClassLoader() && desc.describedClass().getClassLoader() == ldr)
+ return desc;
+ }
+
Class cls;
try {
@@ -468,15 +481,6 @@ public class PortableContext implements Externalizable {
desc = descByCls.get(cls);
}
catch (ClassNotFoundException e) {
- // Class might have been defined explicitly by user. Probably it makes sense to put such classes in
- // specific set.
- if (userType) {
- desc = userTypes.get(typeId);
-
- if (desc != null)
- return desc;
- }
-
throw new PortableInvalidClassException(e);
}
catch (IgniteCheckedException e) {
@@ -566,7 +570,8 @@ public class PortableContext implements Externalizable {
false /* predefined */
);
- // perform put() instead of putIfAbsent() because "registered" flag may have been changed.
+ // perform put() instead of putIfAbsent() because "registered" flag might have been changed or class loader
+ // might have reloaded described class.
userTypes.put(typeId, desc);
descByCls.put(cls, desc);