써먹는 웹개발

[Spring] connection still allocated 오류 해결 방법 본문

Server/Spring

[Spring] connection still allocated 오류 해결 방법

kmhan 2021. 9. 27. 19:22


728x90
반응형

에러 발생한 소스

1
httpclient = new DefaultHttpClient();
cs

 

에러메시지

1
W/SingleClientConnManager(22006): Invalid use of SingleClientConnManager: connection still allocated
cs

 

해결한 방법

1
2
3
4
5
6
7
8
9
public static DefaultHttpClient getThreadSafeClient()  {
        DefaultHttpClient client = new DefaultHttpClient();
        ClientConnectionManager mgr = client.getConnectionManager();
        HttpParams params = client.getParams();
        client = new DefaultHttpClient(new ThreadSafeClientConnManager(params, mgr.getSchemeRegistry()), params);
        return client;
}
 
httpclient = getThreadSafeClient();
cs

 

출처 : https://blog.devflow.kr/170

728x90
반응형


Comments