Add Logging to Mock Repo API Server (#49409)

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
This commit is contained in:
Armin Braun 2019-11-21 11:29:26 +01:00 committed by Tanguy Leroux
parent 3221827a4b
commit df8d7b213b
1 changed files with 11 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer; import com.sun.net.httpserver.HttpServer;
import org.apache.http.HttpStatus; import org.apache.http.HttpStatus;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.message.ParameterizedMessage; import org.apache.logging.log4j.message.ParameterizedMessage;
import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse; import org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse;
@ -72,9 +73,19 @@ public abstract class ESMockAPIBasedRepositoryIntegTestCase extends ESBlobStoreR
private static HttpServer httpServer; private static HttpServer httpServer;
private Map<String, HttpHandler> handlers; private Map<String, HttpHandler> handlers;
private static final Logger log = LogManager.getLogger();
@BeforeClass @BeforeClass
public static void startHttpServer() throws Exception { public static void startHttpServer() throws Exception {
httpServer = MockHttpServer.createHttp(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0), 0); 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(); httpServer.start();
} }