我有一个关闭时,它的触发连接的计时器任务,问题是,有时连接实际上是打开之前被触发,这样的:关闭黑莓的HttpConnection上超时
try {
HttpConnection conn = getMyConnection(); // Asume this returns a valid connection object
// ... At this moment the timer triggers the worker wich closes the connection:
conn.close(); // This is done by the timeTask before conn.getResponseCode()
int mCode = conn.getResponseCode(); // BOOOMMMM!!!! EXPLOTION!!!!
// ... Rest of my code here.
} catch(Throwable e) {
System.out.println("ups..."); // This never gets called... Why?
}
当我尝试conn.getResponseCode()
,抛出一个异常,但不是这样,为什么?
我得到这个错误:ClientProtocol(HttpProtocolBase).transitionToState(int)
行:484和未找到源:S。
下面的帖子很好地解释了这种情况,建议尝试在关闭连接之前获取responseCode或读取输入流。 – 2013-03-05 18:19:38