Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 083c398

Browse files
author
zhourenjian
committed
Clean unnecessary printTrackTrace and add a 30s timeout to HTTPRequest
1 parent 4ba8836 commit 083c398

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

sources/net.sf.j2s.ajax/ajaxcore/net/sf/j2s/ajax/HttpRequest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ private boolean checkAbort() {
400400
private void request() {
401401
try {
402402
connection = (HttpURLConnection) new URL(url).openConnection();
403+
connection.setReadTimeout(30000); // 30 seconds
403404
connection.setDoInput(true);
404405
connection.setRequestMethod(method);
405406
connection.setRequestProperty("User-Agent",
@@ -437,7 +438,7 @@ private void request() {
437438
is = connection.getInputStream();
438439
} catch (IOException e) {
439440
if (checkAbort()) return; // exception caused by abort action
440-
e.printStackTrace();
441+
//e.printStackTrace();
441442
readyState = 4;
442443
if (onreadystatechange != null) {
443444
onreadystatechange.onLoaded();
@@ -545,7 +546,7 @@ private void request() {
545546
*/
546547
} catch (IOException e) {
547548
if (checkAbort()) return; // exception caused by abort action
548-
e.printStackTrace();
549+
//e.printStackTrace();
549550
readyState = 4;
550551
if (onreadystatechange != null) {
551552
onreadystatechange.onLoaded();

0 commit comments

Comments
 (0)