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

ClassCastException while executed javascript returns Integer to js-client

    XMLWordPrintable

Details

    Description

      In case if the javascript returns number, the execution of it over js-client, returns the following error:

      Message:
           java.lang.ClassCastException: java.lang.Integer cannot be cast to [B
         Stacktrace:
           undefined
      
      The code is: 
      
      // mode=local,language=javascript,datatype='text/plain; charset=utf-8'
      cache.size()
      
      The verifying test is:
      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.toBe(0)))
              .catch(failed(done)).finally(done);
        });
      

      There is no exception on server side. Also please find below the log of the node.js execution:

      [2016-03-18 18:10:53.848] [DEBUG] connection - Connecting to 127.0.0.1:11222
      [2016-03-18 18:10:53.849] [DEBUG] connection - Connected to 127.0.0.1:11222
      [2016-03-18 18:10:53.849] [DEBUG] client - Invoke ping(msgId=186)
      [2016-03-18 18:10:53.849] [TRACE] encoder - Encode operation with topology id 0
      [2016-03-18 18:10:53.849] [TRACE] transport - Write buffer(msgId=186) to 127.0.0.1:11222
      [2016-03-18 18:10:53.852] [TRACE] decoder - Read header(msgId=186): opCode=24, status=6, hasNewTopology=0
      [2016-03-18 18:10:53.852] [TRACE] decoder - Call decode for request(msgId=186)
      [2016-03-18 18:10:53.852] [TRACE] connection - After decoding request(msgId=186), buffer size is 6, and offset 6
      [2016-03-18 18:10:53.852] [TRACE] connection - Complete success for request(msgId=186) with undefined
      [2016-03-18 18:10:53.852] [DEBUG] client - Invoke put(msgId=187,key=�>�test-cacheManager.js,value=�>S// mode=local,language=javascript,datatype='text/plain; charset=utf-8'
      cache.size(),opts=undefined)
      [2016-03-18 18:10:53.853] [TRACE] encoder - Encode operation with topology id 0
      [2016-03-18 18:10:53.853] [TRACE] transport - Write buffer(msgId=187) to 127.0.0.1:11222
      [2016-03-18 18:10:53.854] [TRACE] decoder - Read header(msgId=187): opCode=2, status=6, hasNewTopology=0
      [2016-03-18 18:10:53.854] [TRACE] decoder - Call decode for request(msgId=187)
      [2016-03-18 18:10:53.854] [TRACE] connection - After decoding request(msgId=187), buffer size is 6, and offset 6
      [2016-03-18 18:10:53.854] [TRACE] connection - Complete success for request(msgId=187) with undefined
      [2016-03-18 18:10:53.854] [DEBUG] client - Invoke execute(msgId=188,scriptName=test-cacheManager.js,params=undefined)
      [2016-03-18 18:10:53.855] [TRACE] encoder - Encode operation with topology id 0
      [2016-03-18 18:10:53.855] [TRACE] transport - Write buffer(msgId=188) to 127.0.0.1:11222
      [2016-03-18 18:10:53.855] [DEBUG] connection - Disconnected from 127.0.0.1:11222
      [2016-03-18 18:10:53.858] [TRACE] decoder - Read header(msgId=188): opCode=80, status=133, hasNewTopology=0
      [2016-03-18 18:10:53.858] [ERROR] decoder - Error decoding body of request(msgId=188): java.lang.ClassCastException: java.lang.Integer cannot be cast to [B
      [2016-03-18 18:10:53.859] [TRACE] connection - After decoding request(msgId=188), buffer size is 75, and offset 75
      [2016-03-18 18:10:53.859] [TRACE] connection - Complete failure for request(msgId=188) with java.lang.ClassCastException: java.lang.Integer cannot be cast to [B
      [2016-03-18 18:10:53.869] [DEBUG] client - Invoke clear(msgId=189)
      [2016-03-18 18:10:53.869] [TRACE] encoder - Encode operation with topology id 0
      [2016-03-18 18:10:53.869] [TRACE] transport - Write buffer(msgId=189) to 127.0.0.1:11222
      [2016-03-18 18:10:53.869] [TRACE] decoder - Read header(msgId=189): opCode=20, status=0, hasNewTopology=0
      [2016-03-18 18:10:53.869] [TRACE] decoder - Call decode for request(msgId=189)
      [2016-03-18 18:10:53.869] [TRACE] connection - After decoding request(msgId=189), buffer size is 6, and offset 6
      [2016-03-18 18:10:53.869] [TRACE] connection - Complete success for request(msgId=189) with undefined
      [2016-03-18 18:10:53.878] [DEBUG] connection - Disconnected from 127.0.0.1:11222
      

      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: