Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-5870

Error when using Uploader with websockets

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Normal Normal
    • None
    • 10.1.0
    • None
    • None

      Steps to Reproduce

      The issue occurs only when using the Dropupload component with websockets and having pending events to be sent to the server, for example if you previously clicked on the textbox component of the Dropupload.

      Current Result

      The selected document content is sent via POST with other events accumulated that weren't sent inmediately but they're encoded allowing empty fields so eventually it fails on the server side class AuMultipartUploader::splitQueryParameter generating this stacktrace (and failing to upload the document):

      java.lang.NullPointerException: Cannot invoke "String.length()" because "s" is null java.base/java.net.URLDecoder.decode(URLDecoder.java:173) java.base/java.net.URLDecoder.decode(URLDecoder.java:138) org.zkoss.zk.au.http.AuMultipartUploader.splitQueryParameter(AuMultipartUploader.java:188) java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215) java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:1024) java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570) java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560) java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265) java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:727) org.zkoss.zk.au.http.AuMultipartUploader.splitQuery(AuMultipartUploader.java:177) org.zkoss.zk.au.http.AuMultipartUploader$AuMultipartDecoder.<init>(AuMultipartUploader.java:301) org.zkoss.zk.au.http.AuMultipartUploader.parseRequest(AuMultipartUploader.java:166) org.zkoss.zk.au.http.DHtmlUpdateServlet.process(DHtmlUpdateServlet.java:452) org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:408) org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:416)

      Expected Result

       

      Debug Information

       

      Workaround

      I have temporarily solved the issue with this workaround that ensures that there's no empty field

       
      zk.afterLoad('zkmax', function () {
      var xZWs = {};
      zk.override(zkmax.websocket_.zWs, xZWs, {
      encode: function (j, aureq, dt) {
      var content = {},
      opts = aureq.opts || {},
      target = aureq.target;
      content['dtid'] = dt.id;
      content["cmd_".concat(j)] = aureq.name;
      if ((opts.implicit || opts.ignorable) && !opts.serverAlive) content["opt_".concat(j)] = 'i';
      if (target && target.className !== 'zk.Desktop') content["uuid_".concat(j)] = target.uuid;
      var data = aureq.data;
      if (typeof data === 'string' || typeof data === 'number' || typeof data === 'boolean' || Array.isArray(data)) data =

      { '': data }

      ;
      if (data) content["data_".concat(j)] = zAu.toJSON(target, data);
      return content;
      }
      }); //zk.override
      });//zk.afterLoad

            Unassigned Unassigned
            ajrneo ajrneo
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: