Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-4342

NullPointerException in CachedOutputStream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.2
    • 2.3.11, 2.4.8, 2.5.4, 2.6.1
    • None
    • None
    • Unknown

    Description

      The following error occurs from time to time in the CachedOutputStream

      java.lang.NullPointerException
              at org.apache.cxf.io.CachedOutputStream.maybeDeleteTempFile(CachedOutputStream.java:487)[85:org.apache.cxf.bundle:2.4.2]
              at org.apache.cxf.io.CachedOutputStream.close(CachedOutputStream.java:187)[85:org.apache.cxf.bundle:2.4.2]
              at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1561)[85:org.apache.cxf.bundle:2.4.2]
              at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1494)[85:org.apache.cxf.bundle:2.4.2]
              at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$2.run(AutomaticWorkQueueImpl.java:353)[85:org.apache.cxf.bundle:2.4.2]
              at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_29]
              at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_29]
              at java.lang.Thread.run(Thread.java:662)[:1.6.0_29]
      

      The problem is in the following method

      private void maybeDeleteTempFile(Object stream) {
          streamList.remove(stream);
          if (!inmem && tempFile != null && streamList.isEmpty() && allowDeleteOfFile) {
              if (currentStream != null) {
                  try {
                      currentStream.close();
                      postClose();
                  } catch (Exception e) {
                      //ignore
                  }
              }
              tempFile.delete();
              tempFile = null;
              currentStream = new LoadingByteArrayOutputStream(1024);
              inmem = true;
          }
      }
      

      NPE occurs executing the following code tempFile.delete();, so we can conclude that exception is connected with multithreading because before deleting the file there is a check tempFile != null

      Attachments

        1. CachedOutputStream.java.patch
          3 kB
          Sergey Zhemzhitsky

        Activity

          People

            dkulp Daniel Kulp
            szhemzhitsky Sergey Zhemzhitsky
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: