IGNITE-2257: Another attempt to fix BinaryContext serialization.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/67817e80 Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/67817e80 Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/67817e80 Branch: refs/heads/ignite-2257 Commit: 67817e807555cc9f962b869b87a8fed7594e5e29 Parents: 1480ffc Author: vozerov-gridgain <[email protected]> Authored: Thu Dec 24 16:36:57 2015 +0300 Committer: vozerov-gridgain <[email protected]> Committed: Thu Dec 24 16:36:57 2015 +0300 ---------------------------------------------------------------------- .../internal/binary/GridBinaryMarshaller.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/67817e80/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java index 93f3a40..a8cc8ae 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/binary/GridBinaryMarshaller.java @@ -17,10 +17,15 @@ package org.apache.ignite.internal.binary; +import org.apache.ignite.IgniteIllegalStateException; +import org.apache.ignite.internal.IgniteKernal; +import org.apache.ignite.internal.IgnitionEx; import org.apache.ignite.internal.binary.streams.BinaryHeapInputStream; import org.apache.ignite.internal.binary.streams.BinaryInputStream; import org.apache.ignite.internal.binary.streams.BinaryOutputStream; import org.apache.ignite.binary.BinaryObjectException; +import org.apache.ignite.internal.processors.cache.binary.CacheObjectBinaryProcessorImpl; +import org.apache.ignite.internal.processors.cacheobject.IgniteCacheObjectProcessor; import org.jetbrains.annotations.Nullable; /** @@ -350,9 +355,17 @@ public class GridBinaryMarshaller { public static BinaryContext threadLocalContext() { BinaryContext ctx = GridBinaryMarshaller.BINARY_CTX.get(); - if (ctx == null) - throw new IllegalStateException("Failed to get BinaryContext (binary objects can only be deserialized " + - "inside Ignite)."); + if (ctx == null) { + IgniteKernal ignite = IgnitionEx.localIgnite(); + + IgniteCacheObjectProcessor proc = ignite.context().cacheObjects(); + + if (proc instanceof CacheObjectBinaryProcessorImpl) + return ((CacheObjectBinaryProcessorImpl)proc).binaryContext(); + else + throw new IgniteIllegalStateException("Ignite instance must be started with " + + BinaryMarshaller.class.getName() + " [name=" + ignite.name() + ']'); + } return ctx; }
