In projects I have a problem when most of the exceptions are not logged anywhere and nobody knows what happens and why Jersey is not always ready.
My observations are below:
In ServletContainerBridge.run method getServletContainer().init( servletConfig ); can throw any type of unchecked exceptions which are not handled or logged anywhere.
The following block catches only ServletException.
public void run() {
if( application.isDirty() ) {
ClassLoader original = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader( Request.class.getClassLoader() );
synchronized( this ) {
if( !isJerseyReady() ) {
// if jersey has not been initialized - use the init method
getServletContainer().init( servletConfig );
} else {
// otherwise reload
isJerseyReady = false;
getServletContainer().reload( ResourceConfig.forApplication( application ) );
}
isJerseyReady = true;
}
} catch( ServletException e ) {
throw new RuntimeException( e );
} finally {
Thread.currentThread().setContextClassLoader( original );
}
}
If unchecked exception is thrown it goes up to parent level which is executor at ResourcePublisher
private final ScheduledExecutorService executor;
Executor is created as
Step 1: Class JerseyContext
this.resourcePublisher = new ResourcePublisher( servletContainerBridge, configuration.getPublishDelay() );
In projects I have a problem when most of the exceptions are not logged anywhere and nobody knows what happens and why Jersey is not always ready.
My observations are below:
In ServletContainerBridge.run method getServletContainer().init( servletConfig ); can throw any type of unchecked exceptions which are not handled or logged anywhere.
The following block catches only ServletException.
If unchecked exception is thrown it goes up to parent level which is executor at ResourcePublisher
private final ScheduledExecutorService executor;
Executor is created as
Step 1: Class JerseyContext
Step 2: ResourcePublisher
Step 3: ResourcePublisher.createExecutor
where uncaughtException throws IllegalStateException.
I guess this is a critical issue and it would be helpful if at least slf4j logging is introduced as soon as possible.
Thank you,