zstan commented on a change in pull request #8169:
URL: https://github.com/apache/ignite/pull/8169#discussion_r473840587
##########
File path:
modules/core/src/test/java/org/apache/ignite/client/IgniteBinaryTest.java
##########
@@ -123,6 +130,59 @@ public void testBinaryObjectPutGet() throws Exception {
}
}
+ /**
+ * Tests that {@code
org.apache.ignite.cache.CacheInterceptor#onBeforePut(javax.cache.Cache.Entry,
java.lang.Object)}
+ * throws correct exception in case while cache operations are called from
thin client. Only BinaryObject`s are
+ * acceptable in this case.
+ */
+ @Test
+ public void testBinaryWithNotGenericInterceptor() throws Exception {
+ IgniteConfiguration ccfg = Config.getServerConfiguration()
+ .setCacheConfiguration(new
CacheConfiguration("test").setInterceptor(new ThinBinaryValueInterceptor()));
+
+ String castErr = "cannot be cast to";
+ String treeErr = "Tree is corrupted";
+
+ ListeningTestLogger srvLog = new ListeningTestLogger(log);
+
+ LogListener lsnrCast = LogListener.matches(castErr).
+ andMatches(str -> !str.contains(treeErr)).build();
+
+ srvLog.registerListener(lsnrCast);
+
+ ccfg.setGridLogger(srvLog);
+
+ try (Ignite ignored = Ignition.start(ccfg)) {
+ try (IgniteClient client =
+ Ignition.startClient(new
ClientConfiguration().setAddresses(Config.SERVER))
+ ) {
+ ClientCache<Integer, ThinBinaryValue> cache =
client.cache("test");
+
+ try {
+ cache.put(1, new ThinBinaryValue());
+ }
+ catch (Exception e) {
+ assertTrue(X.getFullStackTrace(e).contains(castErr));
Review comment:
current error message has a lot of inner info, yes we talking about it,
if i correctly understand you suggest to add additional exception class and
check it in all exception path places ? I don`t like this approach, or i miss
something, check current exception path :
org.apache.ignite.cache.CachePartialUpdateException: Failed to update keys
(retry update if possible).: [1]
at
org.apache.ignite.internal.processors.cache.GridCacheUtils.convertToCacheException(GridCacheUtils.java:1252)
at
org.apache.ignite.internal.processors.cache.IgniteCacheProxyImpl.cacheException(IgniteCacheProxyImpl.java:2083)
...
at java.lang.Thread.run(Thread.java:748)
Caused by: class
org.apache.ignite.internal.processors.cache.CachePartialUpdateCheckedException:
Failed to update keys (retry update if possible).: [1]
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicAbstractUpdateFuture.onPrimaryError(GridNearAtomicAbstractUpdateFuture.java:397)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicSingleUpdateFuture.onPrimaryResponse(GridNearAtomicSingleUpdateFuture.java:253)
... 13 more
Suppressed: class org.apache.ignite.IgniteCheckedException: Failed to
update keys.
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.UpdateErrors.addFailedKey(UpdateErrors.java:108)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridNearAtomicUpdateResponse.addFailedKey(GridNearAtomicUpdateResponse.java:327)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2808)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.update(GridDhtAtomicCache.java:2128)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateAllAsyncInternal0(GridDhtAtomicCache.java:1945)
... 23 more
Suppressed: class org.apache.ignite.IgniteCheckedException:
Runtime failure on search row: SearchRow [key=KeyCacheObjectImpl [part=1,
val=1, hasValBytes=true], hash=1, cacheId=0]
at
org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invoke(BPlusTree.java:1928)
at
org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke0(IgniteCacheOffheapManagerImpl.java:1712)
at
org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl$CacheDataStoreImpl.invoke(IgniteCacheOffheapManagerImpl.java:1695)
at
org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManagerImpl.invoke(IgniteCacheOffheapManagerImpl.java:444)
at
org.apache.ignite.internal.processors.cache.GridCacheMapEntry.innerUpdate(GridCacheMapEntry.java:2319)
at
org.apache.ignite.internal.processors.cache.distributed.dht.atomic.GridDhtAtomicCache.updateSingle(GridDhtAtomicCache.java:2667)
... 25 more
Caused by: class org.apache.ignite.IgniteCheckedException:
org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to
org.apache.ignite.client.IgniteBinaryTest$ThinBinaryValue
at
org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.update(GridCacheMapEntry.java:6379)
at
org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:6174)
at
org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.call(GridCacheMapEntry.java:5863)
at
org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree$Invoke.invokeClosure(BPlusTree.java:3994)
at
org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree$Invoke.access$5700(BPlusTree.java:3888)
at
org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invokeDown(BPlusTree.java:2014)
at
org.apache.ignite.internal.processors.cache.persistence.tree.BPlusTree.invoke(BPlusTree.java:1898)
... 30 more
Caused by: java.lang.ClassCastException:
org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to
org.apache.ignite.client.IgniteBinaryTest$ThinBinaryValue
at
org.apache.ignite.client.IgniteBinaryTest$ThinBinaryValueInterceptor.onBeforePut(IgniteBinaryTest.java:176)
at
org.apache.ignite.internal.processors.cache.GridCacheMapEntry$AtomicCacheUpdateClosure.update(GridCacheMapEntry.java:6376)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]