We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
If I'm not missing something this is a memory leak if you target unique URLs.
jersey/core-client/src/main/java/org/glassfish/jersey/client/HttpUrlConnectorProvider.java
Line 301 in f35691f
The text was updated successfully, but these errors were encountered:
This is indeed a memory leak. This map can only increase in size.
I suggest this class to take the following shape:
private static class DefaultConnectionFactory implements ConnectionFactory { private final ConcurrentHashMap<URL, Semaphore> locks = new ConcurrentHashMap<>(); @Override public HttpURLConnection getConnection(URL url) throws IOException { return connect(url, null); } @Override public HttpURLConnection getConnection(URL url, Proxy proxy) throws IOException { return connect(url, proxy); } private HttpURLConnection connect(URL url, Proxy proxy) throws IOException { Semaphore thisThreadLock = new Semaphore(0); Semaphore previousThreadLock = locks.putIfAbsent(url, thisThreadLock); try { if (previousThreadLock != null) { previousThreadLock.acquireUninterruptibly(); } return proxy == null ? (HttpURLConnection) url.openConnection() : (HttpURLConnection) url.openConnection(proxy); } finally { locks.remove(url, thisThreadLock); thisThreadLock.release(); } } }
Sorry, something went wrong.
Thank you for reporting this. We have a fix in progress: #5794
Successfully merging a pull request may close this issue.
If I'm not missing something this is a memory leak if you target unique URLs.
jersey/core-client/src/main/java/org/glassfish/jersey/client/HttpUrlConnectorProvider.java
Line 301 in f35691f
The text was updated successfully, but these errors were encountered: