Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-789

HttpFileObject.doGetInputStream() does not release connection when an exception is thrown, such as the http method return status code is not 200

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.4, 2.3, 2.4.1, 2.5.0, 2.6.0
    • 2.4, 2.3, 2.4.1, 2.5.0, 2.6.0
    • None

    Description

      org.apache.commons.vfs2.provider.http.HttpFileObject.doGetInputStream() does not release connection when an exception is thrown, such as the http method return status code is not 200.

      When throw the FileSystemException, the connection was not released.

      The return status code of 404,can be released by garbage collector in MultiThreadedHttpConnectionManager. But 403 can't.

      // org.apache.commons.vfs2.provider.http.HttpFileObject
      
      // version 2.6.0
      @Override
      protected InputStream doGetInputStream(final int bufferSize) throws Exception {
          final GetMethod getMethod = new GetMethod();
          setupMethod(getMethod);
          final int status = getAbstractFileSystem().getClient().executeMethod(getMethod);
          if (status == HttpURLConnection.HTTP_NOT_FOUND) {
              throw new FileNotFoundException(getName());
          }
          if (status != HttpURLConnection.HTTP_OK) {
              throw new FileSystemException("vfs.provider.http/get.error", getName(), Integer.valueOf(status));
          }
      
          return new HttpInputStream(getMethod, bufferSize);
      }
      
      // org.apache.commons.vfs2.provider.http.HttpFileObject
      
      // version 2.3
      @Override
      protected InputStream doGetInputStream() throws Exception {
          final GetMethod getMethod = new GetMethod();
          setupMethod(getMethod);
          final int status = getAbstractFileSystem().getClient().executeMethod(getMethod);
          if (status == HttpURLConnection.HTTP_NOT_FOUND) {
              throw new FileNotFoundException(getName());
          }
          if (status != HttpURLConnection.HTTP_OK) {
              throw new FileSystemException("vfs.provider.http/get.error", getName(), Integer.valueOf(status));
          }
      
          return new HttpInputStream(getMethod);
      }
      
      

       

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            mick1992 Mick Woo
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: