dropwizard
dropwizard copied to clipboard
Unable to use custom ExceptionMapper in 0.8 due to changes in Jersey 2
Under Jersey 1.x it was possible to remove the Dropwizard standard LoggingExceptionMapper during application configuration like so -
for (Iterator<Object> it = environment.jersey().getResourceConfig().getSingletons().iterator(); it.hasNext();) {
Object object = it.next();
if (LoggingExceptionMapper.class.isAssignableFrom(object.getClass())) {
it.remove();
}
}
However, on dropwizard 0.8rc1 Jersey now returns an unmodifiable collection this for the getSingletons() call -
@Override
public final Set<Object> getSingletons() {
if (cachedSingletonsView == null) {
cachedSingletons = _getSingletons();
cachedSingletonsView = Collections.unmodifiableSet(cachedSingletons == null ? new HashSet<>() : cachedSingletons);
}
return cachedSingletonsView;
}
... so the configuration can no longer be changed after it has been registered.
Is there a workaround for this issue?
Sounds like a duplicate of #710
Yes, sorry this can be closed.