使用 HttpRequest.execute() 的异常:单客户端管理的无效使用:连接仍已分配
2022-08-31 12:22:35
我正在使用google-api-client-java 1.2.1-alpha来执行POST请求,当我执行HttpRequest()时,我得到了以下堆栈跟踪。
在我捕获并忽略从上一个POST到同一URL的403错误之后,它立即发生,并重新使用传输进行后续请求。(它在一个循环中,将多个条目插入到同一个ATOM源)。
在403之后,我应该做些什么来“清理”吗?
Exception in thread "main" java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
at org.apache.http.impl.conn.SingleClientConnManager.getConnection(SingleClientConnManager.java:199)
at org.apache.http.impl.conn.SingleClientConnManager$1.getConnection(SingleClientConnManager.java:173)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:390)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:641)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:576)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:554)
at com.google.api.client.apache.ApacheHttpRequest.execute(ApacheHttpRequest.java:47)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:207)
at au.com.machaira.pss.gape.RedirectHandler.execute(RedirectHandler.java:38)
at au.com.machaira.pss.gape.ss.model.records.TableEntry.executeModification(TableEntry.java:81)
为什么我下面的代码会尝试获取新连接?