Uploaded image for project: 'Red Hat Data Grid'
  1. Red Hat Data Grid
  2. JDG-334

Cache entry is not available in JS client while putting it directly from javascript which is executed over JS client

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • JDG 7.0.0 ER6
    • JDG 7.0.0 ER5
    • HotRod JS client
    • None

      When data is put into the cache while javascript execution on the server over JS Client, i.e. the data is put into the cache in executable js file, then the put data is not readable from the client itself.

      For example, if the https://github.com/infinispan/js-client/blob/master/spec/tests.js files execPutGet function is changed this way:

      exports.execPutGet = function(path, prefix, client, expectFun) {
        return function(done) {
          var scriptName = prefix + '-typed-put-get.js';
          var params = {k: prefix + '-typed-key', v: prefix + '-typed-value'};
          client
            .then(t.loadAndExec(path, scriptName))
            .then(t.assert(t.exec(scriptName, params), expectFun))
              .then(t.assert(t.get(prefix + "-typed-key"), t.toBe(prefix + "-typed-value")))
            /*.then(function(cli) {
                return cli.iterator(1).then(
                    function(it) {
                        function loop(promise, fn) {
                            // Simple recursive loop over iterator's next() call
                            return promise.then(fn).then(function (entry) {
                                return !entry.done ? loop(it.next(), fn) : entry.value;
                            });
                        }
      
                        return loop(it.next(), function (entry) {
                            console.log('iterator.next()=' + JSON.stringify(entry));
                            return entry;
                        });
      
                    }
                )
                        })*/
            .catch(t.failed(done)).finally(done);
        }
      };
      

      then the assertion will fail with error:
      Expected undefined to be 'dist-cluster-typed-value'.

      If you will comment the line with get, and uncomment the iterator part, then the following exception is thrown on the server side:

      16:36:19,785 ERROR [org.infinispan.server.hotrod.HotRodEncoder] (HotRodServerWorker-8-5) ISPN005022: Exception writing response with messageId=77: java.lang.ClassCastException: java.lang.String cannot be cast to [B
      	at org.infinispan.server.hotrod.Encoder2x$$anonfun$writeResponse$9.apply(Encoder2x.scala:364)
      	at org.infinispan.server.hotrod.Encoder2x$$anonfun$writeResponse$9.apply(Encoder2x.scala:343)
      	at scala.collection.immutable.List.foreach(List.scala:381)
      	at org.infinispan.server.hotrod.Encoder2x$.writeResponse(Encoder2x.scala:343)
      	at org.infinispan.server.hotrod.HotRodEncoder.encode(HotRodEncoder.scala:45)
      	at io.netty.handler.codec.MessageToByteEncoder.write(MessageToByteEncoder.java:107)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:619)
      	at io.netty.channel.AbstractChannelHandlerContext.access$1800(AbstractChannelHandlerContext.java:32)
      	at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:904)
      	at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:956)
      	at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:889)
      	at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358)
      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:374)
      	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112)
      	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
      	at java.lang.Thread.run(Thread.java:745)
      

      Seems that the data which is put from the executable js (no matter whether the data which is put is passed as a parameter or was just written in the js itself), is stored in the cache as a byte. And the get operation directly from that script works, but from client itself doesn't.

      The issue appears for both local and clustered modes.

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

                Created:
                Updated:
                Resolved: