aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2014-04-22 22:08:11 -0400
committerHans-Christoph Steiner <hans@eds.org>2015-05-08 16:18:44 -0400
commit5ab6cd87ebc604c40918e694c47cc51a1af99b6a (patch)
treef3a9c835b1c118a61cf889c5bc2bac3171ef5177 /core
parent3526d931ae635536355e46a6b242405d309c70f3 (diff)
downloadnanohttpd-5ab6cd87ebc604c40918e694c47cc51a1af99b6a.tar.gz
do not print stacktrace on SocketTimeoutException
This can happen frequently, so no need to pollute the log.
Diffstat (limited to 'core')
-rw-r--r--core/src/main/java/fi/iki/elonen/NanoHTTPD.java10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
index f797557..4c7a0e4 100644
--- a/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
+++ b/core/src/main/java/fi/iki/elonen/NanoHTTPD.java
@@ -214,8 +214,11 @@ public abstract class NanoHTTPD {
}
} catch (Exception e) {
// When the socket is closed by the client, we throw our own SocketException
- // to break the "keep alive" loop above.
- if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage()))) {
+ // to break the "keep alive" loop above. If the exception was anything other
+ // than the expected SocketException OR a SocketTimeoutException, print the
+ // stacktrace
+ if (!(e instanceof SocketException && "NanoHttpd Shutdown".equals(e.getMessage())) &&
+ !(e instanceof SocketTimeoutException)) {
LOG.log(Level.SEVERE, "Communication with the client broken", e);
}
} finally {
@@ -986,6 +989,9 @@ public abstract class NanoHTTPD {
// throw it out to close socket object (finalAccept)
throw e;
} catch (SocketTimeoutException ste) {
+ // treat socket timeouts the same way we treat socket exceptions
+ // i.e. close the stream & finalAccept object by throwing the
+ // exception up the call stack.
throw ste;
} catch (IOException ioe) {
Response r = new Response(Response.Status.INTERNAL_ERROR, MIME_PLAINTEXT, "SERVER INTERNAL ERROR: IOException: " + ioe.getMessage());