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

DropUpload causes NPE when filesize is close to or equal maxsize.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Normal Normal
    • 8.0.3
    • 8.0.1.1
    • Components
    • Security Level: Jimmy
    • None
    • ZK 8.0.3 S1

      the attached example shows a page 2 upload components

      • button upload
      • drop upload

      When uploading the same files the results are not consistent, and an NPE occurs with a dropupload when the filesize is is almost or equal the maxsize (withing a few hundred bytes)
      I attached 4 test files to illustrate the differences.

      512bytes.txt
      -> both OK upload successful

      2048bytes.txt
      both show an error message -> OK (a bit inconsistent but already raised as ZK-3086)

      896bytes.txt
      button upload -> rejected (counting request size not file size, expected according to the current implementation setSizeMax vs setFileSizeMax)
      -> Exception in console -> OK

      org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (1082) exceeds the configured maximum (1024)
      

      -> shows error popup -> OK

      drop upload -> same console error

      org.apache.commons.fileupload.FileUploadBase$SizeLimitExceededException: the request was rejected because its size (1082) exceeds the configured maximum (1024)
      

      -> NO error popup -> fires onUpload event leading to an NPE (when trying to access the media object)

      ERROR UiEngineImpl:1481 -
      java.lang.NullPointerException: Null Pointer while evaluating: event.media.name
      at bsh.Name.consumeNextObjectField(Name.java:353)
      at bsh.Name.toObject(Name.java:196)
      at bsh.BSHAmbiguousName.toObject(BSHAmbiguousName.java:54)
      ...

      the same happens with 1024bytes.txt file... above that all files are rejected with an error message


      besides: it is confusing that both components with basically the same task "uploading files" behave differently (DropUpload performing a client side check, checking for correct file sizes, and ignoring any later server side exceptions, while button upload only checks on the server side, using the request size, which is of course more performant since it only relies on the request headers)
      this could be aligned, that both components perform the same client and server side checks, resulting in equal error messages which both are customizable (again refer to ZK-3086)

        1. 1024bytes.txt
          1.0 kB
          cor3000
        2. 2048bytes.txt
          2 kB
          cor3000
        3. 512bytes.txt
          0.5 kB
          cor3000
        4. 896bytes.txt
          0.9 kB
          cor3000
        5. fileuploadsize.zul
          0.5 kB
          cor3000

            wenninghsu wenninghsu
            cor3000 cor3000
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 1 day, 4 hours
                1d 4h