use of io.dropwizard.setup.ExceptionMapperBinder in project dropwizard by dropwizard.
the class DefaultServerFactoryTest method doesNotDefaultExceptionMappers.
@Test
void doesNotDefaultExceptionMappers() {
http.setRegisterDefaultExceptionMappers(false);
assertThat(http.getRegisterDefaultExceptionMappers()).isFalse();
Environment environment = new Environment("test");
http.build(environment);
assertThat(environment.jersey().getResourceConfig().getSingletons()).filteredOn(x -> x instanceof ExceptionMapperBinder).isEmpty();
}
use of io.dropwizard.setup.ExceptionMapperBinder in project dropwizard by dropwizard.
the class AbstractServerFactory method createAppServlet.
protected Handler createAppServlet(Server server, JerseyEnvironment jersey, ObjectMapper objectMapper, Validator validator, MutableServletContextHandler handler, @Nullable Servlet jerseyContainer, MetricRegistry metricRegistry) {
configureSessionsAndSecurity(handler, server);
final String allowedMethodsParam = String.join(",", allowedMethods);
handler.addFilter(AllowedMethodsFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST)).setInitParameter(AllowedMethodsFilter.ALLOWED_METHODS_PARAM, allowedMethodsParam);
if (enableThreadNameFilter) {
handler.addFilter(ThreadNameFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
}
serverPush.addFilter(handler);
if (jerseyContainer != null) {
jerseyRootPath.ifPresent(jersey::setUrlPattern);
jersey.register(new JacksonFeature(objectMapper));
jersey.register(new HibernateValidationBinder(validator));
if (registerDefaultExceptionMappers == null || registerDefaultExceptionMappers) {
jersey.register(new ExceptionMapperBinder(detailedJsonProcessingExceptionMapper));
}
handler.addServlet(new ServletHolder("jersey", jerseyContainer), jersey.getUrlPattern());
}
final InstrumentedHandler instrumented = new InstrumentedHandler(metricRegistry);
instrumented.setServer(server);
instrumented.setHandler(handler);
return instrumented;
}
Aggregations