Skip to content

Commit

Permalink
Add Logging to Mock Repo API Server (#49409)
Browse files Browse the repository at this point in the history
While we log exception in the handler, we may still miss exceptions
hgiher up the execution chain. This adds logging of exceptions to all
operations on the IO loop including connection establishment.

Relates #49401
  • Loading branch information
original-brownbear authored and tlrx committed Nov 21, 2019
1 parent 8445a2c commit fdd8184
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import org.apache.http.HttpStatus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
Expand Down Expand Up @@ -72,9 +73,19 @@ protected interface BlobStoreHttpHandler extends HttpHandler {
private static HttpServer httpServer;
private Map<String, HttpHandler> handlers;

private static final Logger log = LogManager.getLogger();

@BeforeClass
public static void startHttpServer() throws Exception {
httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0);
httpServer.setExecutor(r -> {
try {
r.run();
} catch (Throwable t) {
log.error("Error in execution on mock http server IO thread", t);
throw t;
}
});
httpServer.start();
}

Expand Down

0 comments on commit fdd8184

Please sign in to comment.