@Override public ErrorCondition getCondition() { // Get the ErrorCondition, but only return it if its condition field is populated. // This somewhat retains prior TransportImpl behaviour of returning null when no // condition had been set (by TransportImpl itself) rather than the 'empty' ErrorCondition // object historically used in the other areas. ErrorCondition errorCondition = super.getCondition(); return errorCondition.getCondition() != null ? errorCondition : null; }
static <T> AsyncResult<T> future(T value, ErrorCondition err) { if (err.getCondition() != null) { return Future.failedFuture(err.toString()); } else { return Future.succeededFuture(value); } } }
@Override public void setCondition(ErrorCondition error) { super.setCondition(error); _conditionSet = error != null && error.getCondition() != null; }
public Object get(final int index) { switch(index) { case 0: return _errorCondition.getCondition(); case 1: return _errorCondition.getDescription(); case 2: return _errorCondition.getInfo(); } throw new IllegalStateException("Unknown index " + index); }
@Override public void onSessionFinal(Event e) { if (TRACE_LOGGER.isInfoEnabled()) { final Session session = e.getSession(); ErrorCondition condition = session != null ? session.getCondition() : null; TRACE_LOGGER.info(String.format(Locale.US, "onSessionFinal entityName[%s], condition[%s], description[%s]", this.entityName, condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } }
public void processOnClose(Link link, ErrorCondition condition) { if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("processOnClose linkName[%s], errorCondition[%s], errorDescription[%s]", link.getName(), condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } this.underlyingEntity.onClose(condition); }
@Override public void onClose(ErrorCondition condition) { if (condition == null || condition.getCondition() == null) onLinkCloseComplete(null); else onError(ExceptionUtil.toException(condition)); }
@Override public void onConnectionLocalOpen(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onConnectionLocalOpen: hostname[%s], errorCondition[%s], errorDescription[%s]", connection.getHostname(), error != null ? error.getCondition() : "n/a", error != null ? error.getDescription() : "n/a")); } }
@Override public void onConnectionFinal(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onConnectionFinal: hostname[%s], errorCondition[%s], errorDescription[%s]", connection.getHostname(), error != null ? error.getCondition() : "n/a", error != null ? error.getDescription() : "n/a")); } } }
@Override public void onLinkRemoteClose(Event event) { final Link link = event.getLink(); final ErrorCondition condition = link.getRemoteCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("onLinkRemoteClose linkName[%s], errorCondition[%s], errorDescription[%s]", link.getName(), condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } handleRemoteLinkClosed(event); }
@Override public void onConnectionRemoteClose(Event event) { final Connection connection = event.getConnection(); final ErrorCondition error = connection.getRemoteCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format(Locale.US, "onConnectionRemoteClose: hostname[%s], errorCondition[%s], errorDescription[%s]", connection.getHostname(), error != null ? error.getCondition() : "n/a", error != null ? error.getDescription() : "n/a")); } this.amqpConnection.onConnectionError(error); }
/** * Closes the specified link using the given throwable to set the local ErrorCondition object for the link. * * @param link The link to close. * @param t The throwable to use to determine the error condition object. */ private <T extends ProtonLink<T>> void closeLinkWithError(final ProtonLink<T> link, final Throwable t) { final ErrorCondition ec = AmqpContext.getErrorCondition(t); LOG.debug("closing link with error condition [symbol: {}, description: {}]", ec.getCondition(), ec.getDescription()); link.setCondition(ec); link.close(); }
@Override public void onLinkLocalClose(Event event) { final Link link = event.getLink(); final ErrorCondition condition = link.getCondition(); if (TRACE_LOGGER.isInfoEnabled()) { TRACE_LOGGER.info(String.format("onLinkLocalClose linkName[%s], errorCondition[%s], errorDescription[%s]", link.getName(), condition != null ? condition.getCondition() : "n/a", condition != null ? condition.getDescription() : "n/a")); } closeSession(link, link.getCondition()); }
@Override public void onClose(final ErrorCondition condition) { if (this.sendLink != null) { this.underlyingFactory.deregisterForConnectionError(this.sendLink); } final Exception completionException = (condition != null && condition.getCondition() != null) ? ExceptionUtil.toException(condition) : null; this.onError(completionException); }
@Override public void onClose(ErrorCondition condition) { if (this.receiveLink != null) { this.underlyingFactory.deregisterForConnectionError(MessageReceiver.this.receiveLink); } final Exception completionException = (condition != null && condition.getCondition() != null) ? ExceptionUtil.toException(condition) : null; this.onError(completionException); }
@Override public void inspectOpenedResource(Sender sender) { ErrorCondition condition = sender.getRemoteCondition(); if (condition != null && condition.getCondition() != null) { if (!condition.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) { markAsInvalid("Should have been tagged with unauthorized access error"); } } else { markAsInvalid("Sender should have been opened with an error"); } } });
@Override public void inspectOpenedResource(Receiver receiver) { ErrorCondition condition = receiver.getRemoteCondition(); if (condition != null && condition.getCondition() != null) { if (!condition.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) { markAsInvalid("Should have been tagged with unauthorized access error"); } } else { markAsInvalid("Receiver should have been opened with an error"); } } });
@Override public void inspectOpenedResource(Sender sender) { ErrorCondition condition = sender.getRemoteCondition(); if (condition != null && condition.getCondition() != null) { if (!condition.getCondition().equals(AmqpError.UNAUTHORIZED_ACCESS)) { markAsInvalid("Should have been tagged with unauthorized access error"); } } else { markAsInvalid("Sender should have been opened with an error"); } } });
@Override public void processRemoteClose(AmqpProvider provider) throws IOException { // For unsubscribe we care if the remote signaled an error on the close since // that would indicate that the unsubscribe did not succeed and we want to throw // that from the unsubscribe call. if (getEndpoint().getRemoteCondition().getCondition() != null) { closeResource(provider, AmqpSupport.convertToException(provider, getEndpoint(), getEndpoint().getRemoteCondition()), true); } else { closeResource(provider, null, true); } }
@Override public void processRemoteClose(AmqpProvider provider) throws IOException { // For unsubscribe we care if the remote signaled an error on the close since // that would indicate that the unsubscribe did not succeed and we want to throw // that from the unsubscribe call. if (getEndpoint().getRemoteCondition().getCondition() != null) { closeResource(provider, AmqpSupport.convertToException(provider, getEndpoint(), getEndpoint().getRemoteCondition()), true); } else { closeResource(provider, null, true); } }