IGNITE-2965 Failed to read class name from file on deserialization
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/b912754e Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/b912754e Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/b912754e Branch: refs/heads/ignite-1786 Commit: b912754ec23f3174466d5bb9a62a5c142737dd26 Parents: 9192006 Author: Anton Vinogradov <[email protected]> Authored: Mon Apr 11 17:09:06 2016 +0300 Committer: Anton Vinogradov <[email protected]> Committed: Mon Apr 11 17:09:06 2016 +0300 ---------------------------------------------------------------------- .../ignite/internal/MarshallerContextImpl.java | 7 +- .../processors/cache/GridCacheAdapter.java | 2 +- .../processors/cache/GridCacheProxyImpl.java | 4 +- .../processors/cache/IgniteInternalCache.java | 4 +- .../dht/atomic/GridDhtAtomicCache.java | 4 +- .../distributed/near/GridNearAtomicCache.java | 4 +- .../MarshallerCacheJobRunNodeRestartTest.java | 92 +++++++++++++++++--- .../testsuites/IgniteCacheTestSuite4.java | 3 + 8 files changed, 97 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java index 05fe8ef..2023a58 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/MarshallerContextImpl.java @@ -119,7 +119,7 @@ public class MarshallerContextImpl extends MarshallerContextAdapter { String old; try { - old = cache0.tryPutIfAbsent(id, clsName); + old = cache0.tryGetAndPut(id, clsName); if (old != null && !old.equals(clsName)) throw new IgniteCheckedException("Type ID collision detected [id=" + id + ", clsName1=" + clsName + @@ -177,8 +177,9 @@ public class MarshallerContextImpl extends MarshallerContextAdapter { } } catch (IOException e) { - throw new IgniteCheckedException("Failed to read class name from file [id=" + id + - ", file=" + file.getAbsolutePath() + ']', e); + throw new IgniteCheckedException("Class definition was not found " + + "at marshaller cache and local file. " + + "[id=" + id + ", file=" + file.getAbsolutePath() + ']'); } } finally { http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java index ff4ba6d..58fce3d 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheAdapter.java @@ -2531,7 +2531,7 @@ public abstract class GridCacheAdapter<K, V> implements IgniteInternalCache<K, V } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { // Supported only in ATOMIC cache. throw new UnsupportedOperationException(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java index 03735cf..84c5d73 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProxyImpl.java @@ -1274,11 +1274,11 @@ public class GridCacheProxyImpl<K, V> implements IgniteInternalCache<K, V>, Exte } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { CacheOperationContext prev = gate.enter(opCtx); try { - return delegate.tryPutIfAbsent(key, val); + return delegate.tryGetAndPut(key, val); } finally { gate.leave(prev); http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java index 240fe7a..5294f6a 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/IgniteInternalCache.java @@ -1900,7 +1900,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> { public V getTopologySafe(K key) throws IgniteCheckedException; /** - * Tries to put value in cache. Will fail with {@link GridCacheTryPutFailedException} + * Tries to get and put value in cache. Will fail with {@link GridCacheTryPutFailedException} * if topology exchange is in progress. * * @param key Key. @@ -1908,7 +1908,7 @@ public interface IgniteInternalCache<K, V> extends Iterable<Cache.Entry<K, V>> { * @return Old value. * @throws IgniteCheckedException In case of error. */ - @Nullable public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException; + @Nullable public V tryGetAndPut(K key, V val) throws IgniteCheckedException; /** * @param topVer Locked topology version. http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java index a7eaadf..fc1424c 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/atomic/GridDhtAtomicCache.java @@ -471,7 +471,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { + @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { A.notNull(key, "key", val, "val"); return (V)updateAsync0( @@ -480,7 +480,7 @@ public class GridDhtAtomicCache<K, V> extends GridDhtCacheAdapter<K, V> { null, null, true, - ctx.noVal(), + null, false).get(); } http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java index 5bb9aaa..a7481d3 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/near/GridNearAtomicCache.java @@ -471,8 +471,8 @@ public class GridNearAtomicCache<K, V> extends GridNearCacheAdapter<K, V> { } /** {@inheritDoc} */ - @Nullable @Override public V tryPutIfAbsent(K key, V val) throws IgniteCheckedException { - return dht.tryPutIfAbsent(key, val); + @Nullable @Override public V tryGetAndPut(K key, V val) throws IgniteCheckedException { + return dht.tryGetAndPut(key, val); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java index 482edee..c7aecb4 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/MarshallerCacheJobRunNodeRestartTest.java @@ -17,7 +17,7 @@ package org.apache.ignite.internal.processors.cache; -import java.io.File; +import java.io.Serializable; import java.util.concurrent.Callable; import org.apache.ignite.Ignite; import org.apache.ignite.configuration.IgniteConfiguration; @@ -141,7 +141,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job1 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job2(); + return new Class1(); } } @@ -151,7 +151,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job2 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job3(); + return new Class2(); } } @@ -161,7 +161,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job3 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job4(); + return new Class3(); } } @@ -171,7 +171,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job4 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job5(); + return new Class4(); } } @@ -181,7 +181,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job5 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job6(); + return new Class5(); } } @@ -191,7 +191,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job6 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job7(); + return new Class6(); } } @@ -201,7 +201,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job7 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job8(); + return new Class7(); } } @@ -211,7 +211,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job8 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job9(); + return new Class8(); } } @@ -221,7 +221,7 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job9 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job10(); + return new Class9(); } } @@ -231,7 +231,77 @@ public class MarshallerCacheJobRunNodeRestartTest extends GridCommonAbstractTest static class Job10 implements IgniteCallable { /** {@inheritDoc} */ @Override public Object call() throws Exception { - return new Job1(); + return new Class10(); } } + + /** + * + */ + static class Class1 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class2 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class3 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class4 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class5 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class6 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class7 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class8 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class9 implements Serializable { + // No-op. + } + + /** + * + */ + static class Class10 implements Serializable { + // No-op. + } } http://git-wip-us.apache.org/repos/asf/ignite/blob/b912754e/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java index facdc4f..094558d 100644 --- a/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java +++ b/modules/core/src/test/java/org/apache/ignite/testsuites/IgniteCacheTestSuite4.java @@ -87,6 +87,7 @@ import org.apache.ignite.internal.processors.cache.IgniteInternalCacheTypesTest; import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionAtomicSelfTest; import org.apache.ignite.internal.processors.cache.IgniteStartCacheInTransactionSelfTest; import org.apache.ignite.internal.processors.cache.IgniteSystemCacheOnClientTest; +import org.apache.ignite.internal.processors.cache.MarshallerCacheJobRunNodeRestartTest; import org.apache.ignite.internal.processors.cache.distributed.CacheAffinityEarlyTest; import org.apache.ignite.internal.processors.cache.distributed.CacheGetFutureHangsSelfTest; import org.apache.ignite.internal.processors.cache.distributed.CacheNoValueClassOnServerNodeTest; @@ -318,6 +319,8 @@ public class IgniteCacheTestSuite4 extends TestSuite { suite.addTestSuite(IgniteTxCachePrimarySyncTest.class); suite.addTestSuite(IgniteTxCacheWriteSynchronizationModesMultithreadedTest.class); + suite.addTestSuite(MarshallerCacheJobRunNodeRestartTest.class); + return suite; } } \ No newline at end of file
