ptupitsyn commented on a change in pull request #8169:
URL: https://github.com/apache/ignite/pull/8169#discussion_r473845610



##########
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:
       In my opinion, top-level exception should say "Failed to invoke cache 
interceptor of type T: ClassCastException: 
org.apache.ignite.internal.binary.BinaryObjectImpl cannot be cast to 
org.apache.ignite.client.IgniteBinaryTest$ThinBinaryValue".




----------------------------------------------------------------
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]


Reply via email to