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

NullPointerException while executed javascript returns null to js-client

    XMLWordPrintable

Details

    Description

      In case when executing a javascript on local node, which returns as a result null, the following exception is thrown on the server:

      17:25:26,127 ERROR [org.infinispan.server.hotrod.HotRodEncoder] (HotRodServerWorker-7-119) ISPN005022: Exception writing response with messageId=188: java.lang.NullPointerException
      	at org.infinispan.server.core.transport.ExtendedByteBuf$.writeRangedBytes(ExtendedByteBuf.scala:65)
      	at org.infinispan.server.hotrod.Encoder2x$.writeResponse(Encoder2x.scala:340)
      	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:633)
      	at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:691)
      	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:681)
      	at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:716)
      	at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:954)
      	at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:243)
      	at org.infinispan.server.hotrod.HotRodDecoder.writeResponse(HotRodDecoder.scala:250)
      	at org.infinispan.server.hotrod.HotRodDecoder.customDecodeHeader(HotRodDecoder.scala:209)
      	at org.infinispan.server.hotrod.HotRodDecoder.org$infinispan$server$hotrod$HotRodDecoder$$decodeHeader(HotRodDecoder.scala:97)
      	at org.infinispan.server.hotrod.HotRodDecoder$$anonfun$decode$1.apply$mcV$sp(HotRodDecoder.scala:52)
      	at org.infinispan.server.hotrod.HotRodDecoder.wrapSecurity(HotRodDecoder.scala:224)
      	at org.infinispan.server.hotrod.HotRodDecoder.decode(HotRodDecoder.scala:50)
      	at io.netty.handler.codec.ReplayingDecoder.callDecode(ReplayingDecoder.java:370)
      	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:168)
      	at org.infinispan.server.hotrod.HotRodDecoder.org$infinispan$server$core$transport$StatsChannelHandler$$super$channelRead(HotRodDecoder.scala:32)
      	at org.infinispan.server.core.transport.StatsChannelHandler$class.channelRead(StatsChannelHandler.scala:32)
      	at org.infinispan.server.hotrod.HotRodDecoder.channelRead(HotRodDecoder.scala:32)
      	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
      	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
      	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
      	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:130)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
      	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
      	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
      	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
      	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137)
      	at java.lang.Thread.run(Thread.java:745)
      

      The code is:

      //Executable javascript: 
      
      // mode=local,language=javascript,datatype='text/plain; charset=utf-8'
      cacheManager.getAddress()
      
      
      And the Test: 
      
      it('can execute a script remotely to get node address from cacheManager', function(done) {
          Promise.all([client, readFile('spec/utils/test-cacheManager.js')])
              .then(function(vals) {
                var c = vals[0];
                return c.addScript('test-cacheManager.js', vals[1].toString())
                    .then(function() { return c; } );
              })
              .then(t.assert(t.exec('test-cacheManager.js'),
                             t.toBeUndefined))
              .catch(failed(done)).finally(done);
        });
      

      The result of the test execution is:

      Message:
           java.lang.NullPointerException
         Stacktrace:
           undefined
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: