You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Mick Woo (Jira)" <ji...@apache.org> on 2020/09/29 13:51:00 UTC

[jira] [Created] (VFS-789) 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

Mick Woo created VFS-789:
----------------------------

             Summary: 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
                 Key: VFS-789
                 URL: https://issues.apache.org/jira/browse/VFS-789
             Project: Commons VFS
          Issue Type: Bug
    Affects Versions: 2.6.0, 2.5.0, 2.4.1, 2.3, 2.4
            Reporter: Mick Woo
             Fix For: 2.6.0, 2.5.0, 2.4.1, 2.3, 2.4


rg.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 connect was not released.

 
{code:java}
// 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);
}
{code}
{code:java}
// 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);
}

{code}
 

 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)