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

NPE fileupload when using Websockets (Tomcat)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 8.5.0, 8.5.1.2
    • Fix Version/s: 8.5.2
    • Component/s: ZK Update Engine
    • Security Level: Jean
    • Labels:
    • Environment:

      All browsers (FF more often ... not sure why, must be a timing issue)
      Tested/Reproduced with Tomcat 8.5.29 (Jetty didn't show this issue)

    • gh.sprint.customfield.default.name:
      ZK 8.5.2 S1, ZK 8.5.2 S2

      Description

      Steps to Reproduce

      enable websockets
      run the following zul file

      <zk>
      	<button label="cause problem" onClick='Executions.getCurrent().getParameter("")'/>
      	<button label="upload" upload="true" onUpload='Clients.log("uploaded: " + event.getMedia().getName());'/>
      </zk>
      

      follow the sequence:

      1. upload a file -> Works (upload succeeds)
      2. press the button "cause problem" -> Works (ws request is sent/received - just for the side effect)
      3. upload a file (don't wait too long) -> Sometimes FAILS with a NPE

      Current Result

      If timing is right an exception is thrown:

      Apr 17, 2018 10:28:24 AM org.zkoss.zk.au.http.AuUploader handleError
      SEVERE: Failed to upload
      java.lang.NullPointerException
      	at org.zkoss.xml.XMLs.encodeText(XMLs.java:83)
      	at org.zkoss.zk.au.http.AuUploader.escapeParam(AuUploader.java:477)
      	at org.zkoss.zk.au.http.AuUploader.service(AuUploader.java:143)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doGet(DHtmlUpdateServlet.java:455)
      	at org.zkoss.zk.au.http.DHtmlUpdateServlet.doPost(DHtmlUpdateServlet.java:495)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
      	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:803)
      	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
      	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
      	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      	at java.lang.Thread.run(Thread.java:748)
      

      Expected Result

      Upload works / No exception

      Debug Info

      Problem happens more reliable on FF but can also be reproduced on Chrome/Edge

      The attachment ws-fileupload.zul contains a more debuggable version avoiding additional requests polling for upload percentage.

      The button "cause problem" triggers a WS request accessing calling request.getParameter() on the WSHandshakeRequest.

      1. ws-auext.zul
        1.0 kB
        cor3000
      2. ws-fileupload.zul
        0.6 kB
        cor3000

        Issue Links

          Activity

          Hide
          cor3000 cor3000 added a comment - - edited

          attached simplified test case without file upload ws-auext.zul

          Show
          cor3000 cor3000 added a comment - - edited attached simplified test case without file upload ws-auext.zul
          Hide
          Anonymous added a comment -

          Fixed since 2018/06/29

          Show
          Anonymous added a comment - Fixed since 2018/06/29

            People

            • Assignee:
              wenninghsu wenninghsu
              Reporter:
              cor3000 cor3000
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Agile