public void run() { try { handler.onTimeout(writer); } catch (Exception e) { logger.log(Level.INFO, "Failed to call timeout handler", e); } } }
private void setResponseForInvalidUri(final HttpServletResponse response, final Throwable throwable) throws IOException { LOGGER.log(Level.FINER, "Error while processing request.", throwable); final Response.Status badRequest = Response.Status.BAD_REQUEST; if (webComponent.configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } else { response.sendError(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } }
private void setResponseForInvalidUri(final HttpServletResponse response, final Throwable throwable) throws IOException { LOGGER.log(Level.FINER, "Error while processing request.", throwable); final Response.Status badRequest = Response.Status.BAD_REQUEST; if (webComponent.configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } else { response.sendError(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } }
private void notify(final EventListener listener, final InboundEvent event) { try { listener.onEvent(event); } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, String.format("Event notification in a listener of %s class failed.", listener.getClass().getName()), ex); } } }
@Override public void commit() { try { response.close(); } catch (final IOException e) { logger.log(Level.SEVERE, "Unable to send 500 error response.", e); } finally { logger.debugLog("commit() called"); } }
/** * Await the initial contact with the SSE endpoint. */ public void awaitFirstContact() { LOGGER.debugLog("Awaiting first contact signal."); try { if (firstContactSignal == null) { return; } try { firstContactSignal.await(); } catch (InterruptedException ex) { LOGGER.log(CONNECTION_ERROR_LEVEL, LocalizationMessages.EVENT_SOURCE_OPEN_CONNECTION_INTERRUPTED(), ex); Thread.currentThread().interrupt(); } } finally { LOGGER.debugLog("First contact signal released."); } }
} catch (InterruptedException e) { if (LOGGER.isDebugLoggable()) { LOGGER.log(LOGGER.getDebugLevel(), "Interrupted while waiting for thread pool executor " + executorName + " to shutdown.", e);
} catch (InterruptedException e) { if (LOGGER.isDebugLoggable()) { LOGGER.log(LOGGER.getDebugLevel(), "Interrupted while waiting for thread pool executor " + executorName + " to shutdown.", e);
try { if (!executor.awaitTermination(timeout, unit)) { LOGGER.log(CONNECTION_ERROR_LEVEL, LocalizationMessages.EVENT_SOURCE_SHUTDOWN_TIMEOUT(target.getUri().toString())); return false; LOGGER.log(CONNECTION_ERROR_LEVEL, LocalizationMessages.EVENT_SOURCE_SHUTDOWN_INTERRUPTED(target.getUri().toString())); Thread.currentThread().interrupt();
@Override public void reload(final ResourceConfig configuration) { try { containerListener.onShutdown(this); webComponent = new WebComponent(webComponent.webConfig, configuration); containerListener = webComponent.appHandler; containerListener.onReload(this); containerListener.onStartup(this); } catch (final ServletException ex) { LOGGER.log(Level.SEVERE, "Reload failed", ex); } }
@Override public void reload(final ResourceConfig configuration) { try { containerListener.onShutdown(this); webComponent = new WebComponent(webComponent.webConfig, configuration); containerListener = webComponent.appHandler; containerListener.onReload(this); containerListener.onStartup(this); } catch (final ServletException ex) { LOGGER.log(Level.SEVERE, "Reload failed", ex); } }
@Override public void failure(final Throwable error) { try { if (!response.isCommitted()) { try { if (configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(INTERNAL_SERVER_ERROR, "Request failed."); } else { response.sendError(INTERNAL_SERVER_ERROR, "Request failed."); } } catch (final IllegalStateException ex) { // a race condition externally committing the response can still occur... LOGGER.log(Level.FINER, "Unable to reset failed response.", ex); } catch (final IOException ex) { throw new ContainerException(LocalizationMessages.EXCEPTION_SENDING_ERROR_RESPONSE(INTERNAL_SERVER_ERROR, "Request failed."), ex); } } } finally { LOGGER.log(Level.FINEST, "failure(...) called"); commit(); rethrow(error); } }
} catch (Exception ex) { if (LOGGER.isLoggable(CONNECTION_ERROR_LEVEL)) { LOGGER.log(CONNECTION_ERROR_LEVEL, String.format("Unable to connect - closing the event source to %s.", target.getUri().toASCIIString()), ex);
@Override @SuppressWarnings("MagicNumber") public void failure(final Throwable error) { try { if (!grizzlyResponse.isCommitted()) { try { if (configSetStatusOverSendError) { grizzlyResponse.reset(); grizzlyResponse.setStatus(500, "Request failed."); } else { grizzlyResponse.sendError(500, "Request failed."); } } catch (final IllegalStateException ex) { // a race condition externally committing the response can still occur... logger.log(Level.FINER, "Unable to reset failed response.", ex); } catch (final IOException ex) { throw new ContainerException( LocalizationMessages.EXCEPTION_SENDING_ERROR_RESPONSE(500, "Request failed."), ex); } } } finally { logger.debugLog("{0} - failure(...) called", name); rethrow(error); } }
public void run() { try { handler.onTimeout(writer); } catch (Exception e) { logger.log(Level.INFO, "Failed to call timeout handler", e); } } }
private void setResponseForInvalidUri(final HttpServletResponse response, final Throwable throwable) throws IOException { LOGGER.log(Level.FINER, "Error while processing request.", throwable); final Response.Status badRequest = Response.Status.BAD_REQUEST; if (webComponent.configSetStatusOverSendError) { response.reset(); //noinspection deprecation response.setStatus(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } else { response.sendError(badRequest.getStatusCode(), badRequest.getReasonPhrase()); } }
private void notify(final EventListener listener, final InboundEvent event) { try { listener.onEvent(event); } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, String.format("Event notification in a listener of %s class failed.", listener.getClass().getName()), ex); } } }
private void notify(final EventListener listener, final InboundEvent event) { try { listener.onEvent(event); } catch (Exception ex) { if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, String.format("Event notification in a listener of %s class failed.", listener.getClass().getName()), ex); } } }
@Override public void reload(final ResourceConfig configuration) { try { containerListener.onShutdown(this); webComponent = new WebComponent(webComponent.webConfig, configuration); containerListener = webComponent.appHandler; containerListener.onReload(this); containerListener.onStartup(this); } catch (final ServletException ex) { LOGGER.log(Level.SEVERE, "Reload failed", ex); } }