You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2022/09/03 13:18:00 UTC

[jira] [Commented] (VFS-824) Http4FileSystem - Connection pool shut down

    [ https://issues.apache.org/jira/browse/VFS-824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17599921#comment-17599921 ] 

Gary D. Gregory commented on VFS-824:
-------------------------------------

[~Destiny] 

You might be speedier help if you provide your use case as a failing unit test as a PR on GitHub.

> Http4FileSystem - Connection pool shut down
> -------------------------------------------
>
>                 Key: VFS-824
>                 URL: https://issues.apache.org/jira/browse/VFS-824
>             Project: Commons VFS
>          Issue Type: Bug
>         Environment: Java8
> windows
>            Reporter: 谢裕亮
>            Priority: Major
>
> import org.apache.commons.vfs2.FileObject;
> import org.apache.commons.vfs2.FileSystemException;
> import org.apache.commons.vfs2.FileSystemManager;
> import org.apache.commons.vfs2.cache.WeakRefFilesCache;
> import org.apache.commons.vfs2.impl.StandardFileSystemManager;
> import org.apache.commons.vfs2.provider.AbstractFileSystem;
> import java.io.IOException;
> /**
> * @Date 2022年09月01日 14:10
> * @Description TODO
> */
> public class TestHttpFileSystem {
> public static void main(String[] args) throws IOException, InterruptedException {
> try (StandardFileSystemManager fileSystemManager = new StandardFileSystemManager()) {
> fileSystemManager.setConfiguration(StandardFileSystemManager.class.getResource("providers.xml"));
> fileSystemManager.setFilesCache(new WeakRefFilesCache());
> // fileSystemManager.setFilesCache(new SoftRefFilesCache());
> fileSystemManager.init();
> String path = "http4://images5.alphacoders.com/796/796745.png";
> AbstractFileSystem http4FileSystem = getFile(fileSystemManager, path);
> System.out.println(http4FileSystem.isReleaseable());
> while (!http4FileSystem.isReleaseable()) {
> System.out.println("Try GC");
> // GC
> System.gc();
> }
> // free resource
> // http4FileSystem.httpclient is closed
> fileSystemManager.freeUnusedResources();
> // fileSystemManager.closeFileSystem(http4FileSystem);
> // get file again
> getFile(fileSystemManager, path);
> // Caused by: java.lang.IllegalStateException: Connection pool shut down
> // at org.apache.http.util.Asserts.check(Asserts.java:34)
> // at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:269)
> // at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176)
> // at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
> // at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
> // at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
> // at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
> // at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
> // at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
> // at org.apache.commons.vfs2.provider.http4.Http4FileObject.executeHttpUriRequest(Http4FileObject.java:191)
> // at org.apache.commons.vfs2.provider.http4.Http4FileObject.doGetType(Http4FileObject.java:156)
> // at org.apache.commons.vfs2.provider.AbstractFileObject.getType(AbstractFileObject.java:1375)
> // ... 2 more
> }
> }
> private static AbstractFileSystem getFile(FileSystemManager fileSystemManager, String path) throws FileSystemException {
> FileObject fileObject = fileSystemManager.resolveFile(path);
> System.out.println("File Type Is " + fileObject.getType());
> return (AbstractFileSystem) fileObject.getFileSystem();
> }
> }



--
This message was sent by Atlassian Jira
(v8.20.10#820010)