@Override protected void onConnectionFailed(Throwable t) { log.log(Level.WARNING, "HTTP connection failed: " + requestMessage, Exceptions.unwrap(t)); }
@Override protected void onException(Throwable t) { log.log(Level.WARNING, "HTTP request failed: " + requestMessage, Exceptions.unwrap(t)); }
/** * Handles errors when network has been switched, during reception of * network switch broadcast. Logs a warning by default, override to * change this behavior. */ protected void handleRouterExceptionOnNetworkTypeChange(RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Router was interrupted: " + ex, cause); } else { log.log(Level.WARNING, "Router error on network change: " + ex, ex); } }
@Override public void handleStartFailure(InitializationException ex) throws InitializationException { if (ex instanceof NoNetworkException) { log.info("Unable to initialize network router, no network found."); } else { log.severe("Unable to initialize network router: " + ex); log.severe("Cause: " + Exceptions.unwrap(ex)); } }
@Override protected URI valueOf(String s) throws InvalidValueException { try { // These URIs are really defined as 'string' datatype in AVTransport1.0.pdf, but we can try // to parse whatever devices give us, like the Roku which sends "unknown url". return super.valueOf(s); } catch (InvalidValueException ex) { log.info("Ignoring invalid URI in evented value '" + s +"': " + Exceptions.unwrap(ex)); return null; } }
public void run() { try { execute(); } catch (Exception ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Interrupted protocol '" + getClass().getSimpleName() + "': " + ex, cause); } else { throw new RuntimeException( "Fatal error while executing protocol '" + getClass().getSimpleName() + "': " + ex, ex ); } } }
@Override protected void afterExecute(Runnable runnable, Throwable throwable) { super.afterExecute(runnable, throwable); if (throwable != null) { Throwable cause = Exceptions.unwrap(throwable); if (cause instanceof InterruptedException) { // Ignore this, might happen when we shutdownNow() the executor. We can't // log at this point as the logging system might be stopped already (e.g. // if it's a CDI component). return; } // Log only log.warning("Thread terminated " + runnable + " abruptly with exception: " + throwable); log.warning("Root cause: " + cause); } } }
protected void shutdownRouter() { try { getRouter().shutdown(); } catch (RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Router shutdown was interrupted: " + ex, cause); } else { log.log(Level.SEVERE, "Router error on shutdown: " + ex, cause); } } }
public void run() { boolean proceed; try { proceed = waitBeforeExecution(); } catch (InterruptedException ex) { log.info("Protocol wait before execution interrupted (on shutdown?): " + getClass().getSimpleName()); proceed = false; } if (proceed) { try { execute(); } catch (Exception ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { log.log(Level.INFO, "Interrupted protocol '" + getClass().getSimpleName() + "': " + ex, cause); } else { throw new RuntimeException( "Fatal error while executing protocol '" + getClass().getSimpleName() + "': " + ex, ex ); } } } }
/** * Removes a property change listener on the {@link org.fourthline.cling.model.ServiceManager}. */ synchronized public void end(CancelReason reason) { try { getService().getManager().getPropertyChangeSupport().removePropertyChangeListener(this); } catch (Exception ex) { log.warning("Removal of local service property change listener failed: " + Exceptions.unwrap(ex)); } ended(reason); }
public StreamResponseMessage call() throws Exception { if (log.isLoggable(Level.FINE)) log.fine("Sending HTTP request: " + requestMessage); client.send(exchange); int exchangeState = exchange.waitForDone(); if (exchangeState == HttpExchange.STATUS_COMPLETED) { try { return exchange.createResponse(); } catch (Throwable t) { log.log(Level.WARNING, "Error reading response: " + requestMessage, Exceptions.unwrap(t)); return null; } } else if (exchangeState == HttpExchange.STATUS_CANCELLED) { // That's ok, happens when we abort the exchange after timeout return null; } else if (exchangeState == HttpExchange.STATUS_EXCEPTED) { // The warnings of the "excepted" condition are logged in HttpContentExchange return null; } else { log.warning("Unhandled HTTP exchange status: " + exchangeState); return null; } } };
getConfiguration().getAsyncProtocolExecutor().execute(protocol); } catch (ProtocolCreationException ex) { log.warning("Handling received datagram failed - " + Exceptions.unwrap(ex).toString());
@Override public void startElement(String uri, String localName, String qName, final Attributes attributes) throws SAXException { super.startElement(uri, localName, qName, attributes); Map.Entry[] attributeMap = new Map.Entry[attributes.getLength()]; for (int i = 0; i < attributeMap.length; i++) { attributeMap[i] = new AbstractMap.SimpleEntry<>( attributes.getLocalName(i), attributes.getValue(i) ); } try { EventedValue esv = createValue(localName, attributeMap); if (esv != null) getInstance().getValues().add(esv); } catch (Exception ex) { // Don't exit, just log a warning log.warning("Error reading event XML, ignoring value: " + Exceptions.unwrap(ex)); } }
} catch (Exception ex) { log.severe("Error instantiating header of type '" + type + "' with value: " + headerValue); log.log(Level.SEVERE, "Exception root cause: ", Exceptions.unwrap(ex));
protected void handleResponseFailure(IncomingActionResponseMessage responseMsg) throws ActionException { try { log.fine("Received response with Internal Server Error, reading SOAP failure message"); getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation); } catch (UnsupportedDataException ex) { log.fine("Error reading SOAP body: " + ex); log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex)); throw new ActionException( ErrorCode.ACTION_FAILED, "Error reading SOAP response failure message. " + ex.getMessage(), false ); } }
protected void handleResponse(IncomingActionResponseMessage responseMsg) throws ActionException { try { log.fine("Received response for outgoing call, reading SOAP response body: " + responseMsg); getUpnpService().getConfiguration().getSoapActionProcessor().readBody(responseMsg, actionInvocation); } catch (UnsupportedDataException ex) { log.fine("Error reading SOAP body: " + ex); log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex)); throw new ActionException( ErrorCode.ACTION_FAILED, "Error reading SOAP response message. " + ex.getMessage(), false ); } }
log.warning("Processing stream request failed - " + Exceptions.unwrap(ex).toString()); return new StreamResponseMessage(UpnpResponse.Status.NOT_IMPLEMENTED);
protected StreamResponseMessage sendRemoteRequest(OutgoingActionRequestMessage requestMessage) throws ActionException, RouterException { try { log.fine("Writing SOAP request body of: " + requestMessage); getUpnpService().getConfiguration().getSoapActionProcessor().writeBody(requestMessage, actionInvocation); log.fine("Sending SOAP body of message as stream to remote device"); return getUpnpService().getRouter().send(requestMessage); } catch (RouterException ex) { Throwable cause = Exceptions.unwrap(ex); if (cause instanceof InterruptedException) { if (log.isLoggable(Level.FINE)) { log.fine("Sending action request message was interrupted: " + cause); } throw new ActionCancelledException((InterruptedException)cause); } throw ex; } catch (UnsupportedDataException ex) { if (log.isLoggable(Level.FINE)) { log.fine("Error writing SOAP body: " + ex); log.log(Level.FINE, "Exception root cause: ", Exceptions.unwrap(ex)); } throw new ActionException(ErrorCode.ACTION_FAILED, "Error writing request message. " + ex.getMessage()); } }
); } catch (InvalidValueException ex) { log.warning("In DIDL content, invalid resource protocol info: " + Exceptions.unwrap(ex)); return null;