Uploaded image for project: 'Infinispan'
  1. Infinispan
  2. ISPN-6411

Marshalled value is returned while executing javascript and returning value from cache over HotRod client

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 9.0.0.Final
    • 8.2.1.Final
    • Remote Protocols
    • None
    • Workaround Exists
    • Hide

      If in the test1.js place the code of getting cache from the cacheManager, then the issue doesn't happen. So the javascript should be:

      //test1.js
      // mode=local,language=javascript
      var cache = cacheManager.getCache("testRemoteScriptRemoteExecution_REPL_SYNC");
      cache.put("a", "hoptimus prime");
      cache.get("a");
      
      Show
      If in the test1.js place the code of getting cache from the cacheManager, then the issue doesn't happen. So the javascript should be: //test1.js // mode=local,language=javascript var cache = cacheManager.getCache( "testRemoteScriptRemoteExecution_REPL_SYNC" ); cache.put( "a" , "hoptimus prime" ); cache.get( "a" );

      When trying to execute a script over hotrod-client, which puts some data to the cache and returns it, the test fails with the following exception:

      java.lang.ClassCastException: [B cannot be cast to java.lang.String
      
      	at org.infinispan.client.hotrod.ExecTest.testRemoteScriptRemoteExecution(ExecTest.java:122)
      	...
      

      The test code and javascript code are:

      @Test
         public void testRemoteScriptRemoteExecution() throws IOException {
            String cacheName = "testRemoteScriptRemoteExecution_REPL_SYNC";
            ConfigurationBuilder builder = getDefaultClusteredCacheConfig(CacheMode.REPL_SYNC, true);
            builder.dataContainer().keyEquivalence(new AnyServerEquivalence()).valueEquivalence(new AnyServerEquivalence()).compatibility().enable().marshaller(new GenericJBossMarshaller());
            defineInAll(cacheName, builder);
            try (InputStream is = this.getClass().getResourceAsStream("/test1.js")) {
               String script = TestingUtil.loadFileAsString(is);
               clients.get(0).getCache(SCRIPT_CACHE).put("testRemoteScriptRemoteExecution.js", script);
            }
      
            Map<String, String> params = new HashMap<>();
      
            String result = clients.get(0).getCache(cacheName).execute("testRemoteScriptRemoteExecution.js", params);    //<- The exception is thrown here while casting to String
            assertEquals("hoptimus prime", result);
            assertEquals("hoptimus prime", clients.get(0).getCache(cacheName).get("a"));
         }
      
      //test1.js
      // mode=local,language=javascript
      cache.put("a", "hoptimus prime");
      cache.get("a");
      

              rh-ee-galder Galder ZamarreƱo
              amanukya@redhat.com Anna Manukyan
              Archiver:
              rhn-support-adongare Amol Dongare

                Created:
                Updated:
                Resolved:
                Archived: