我有一个定时器任务,它在触发时关闭连接,问题是有时它在连接实际打开之前被触发,如下所示:
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。