Uploaded image for project: 'Commons FileUpload'
  1. Commons FileUpload
  2. FILEUPLOAD-134

A factory-created DiskFileItem does not have an initialized dfos, causing NullPointerExceptions if getOutputStream() is not called.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2
    • 1.2.1
    • None

    Description

      When upgrading the Turbine code to commons-fileupload 1.2, I got NPEs in Unit tests dealing with DiskFileItems. In that special case, a FileItem was created like this:

      ParameterParser pp = new DefaultParameterParser();
      DiskFileItemFactory factory = new DiskFileItemFactory(10240, new File("."));

      FileItem test = factory.createItem("upload-field", "application/octet-stream", false, null);

      pp.add("upload-field", test);

      assertTrue(pp.toString().startsWith("{upload-field=[name=null"));

      pp.toString() causes a call to test.toString() which (among other things) calls dfos.getFile(). This fails because dfos is not initialized before getOutputStream() is called.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tv Thomas Vandahl
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: