Skip to content

Commit

Permalink
Ignore certain exception logging for UI server.
Browse files Browse the repository at this point in the history
  • Loading branch information
hptruong93 committed Nov 19, 2022
1 parent 6dc7a15 commit 70c6c61
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/core/webui/server/UIServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.http.ExceptionLogger;
import org.apache.http.impl.nio.bootstrap.HttpServer;
import org.apache.http.impl.nio.bootstrap.ServerBootstrap;
import org.apache.http.impl.nio.reactor.IOReactorConfig;
Expand Down Expand Up @@ -320,7 +319,7 @@ protected void start() throws IOException {
.setIOReactorConfig(IOReactorConfig.custom().setSoReuseAddress(true).build())
.setListenerPort(port)
.setServerInfo("Repeat")
.setExceptionLogger(ExceptionLogger.STD_ERR)
.setExceptionLogger(new UIServerExceptionLogger())
.registerHandler("/test", new UpAndRunningHandler())
.registerHandler("/static/*", new StaticFileServingHandler());
for (Entry<String, HttpHandlerWithBackend> entry : handlers.entrySet()) {
Expand Down
21 changes: 21 additions & 0 deletions src/core/webui/server/UIServerExceptionLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package core.webui.server;

import java.io.IOException;

import org.apache.http.ExceptionLogger;

/**
* Logger that ignores certain commonly encountered (but harmless) exceptions.
*/
public class UIServerExceptionLogger implements ExceptionLogger {
@Override
public void log(Exception arg0) {
if (arg0 instanceof IOException) {
if (arg0.getLocalizedMessage().contains("An established connection was aborted by the software in your host machine")) {
return;
}
}

arg0.printStackTrace();
}
}

0 comments on commit 70c6c61

Please sign in to comment.