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

    XMLWordPrintable

Details

    • 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" );

    Description

      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");
      

      Attachments

        Issue Links

          Activity

            People

              rh-ee-galder Galder ZamarreƱo
              amanukya@redhat.com Anna Manukyan
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: