thread will block forever when server not return all data
WoodLewis opened this issue · comments
the default conection timeout and read timeout of HttpURLConnection is -1 which means the socket will always wait to read data and block the user thread forever if server not finish the connect,so the user thread seems to stop running.
to fix this bug may change "load" method of "RSSReader" like below:
......
private int readTimeout=30000;
private int connectTimeout=30000;
......
public RSSFeed load(String uri) throws RSSReaderException{
......
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(readTimeout);
conn.setReadTimeout(connectTimeout);
conn.connect();
......
}