GH-2748: More bean definitions into exceptions

Fixes https://github.com/spring-projects/spring-integration/issues/2748

* Refactor more `MessageHandlingException`s to include `this` into an
exception message
* Revert using `MessagingException` in some places which really are not
about messaging.
This helps to wrap them into `MessageHandlingException` later in the
`MessageHandler` for the `BeanDefinition` reference
* Remove `volatile` from configuration properties in the affected
classes
* Remove already deprecated `JmsOutboundGateway.setPriority()`
* Add `resource` and `source` for `BeanDefinition` in the
`AbstractChannelAdapterParser` & `AbstractInboundGatewayParser`
* Document the feature
This commit is contained in:
Artem Bilan
2019-07-23 14:01:05 -04:00
committed by Gary Russell
parent 0ed88c3268
commit 80d679a9b0
46 changed files with 352 additions and 370 deletions

View File

@@ -116,6 +116,7 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
public WebSocketInboundChannelAdapter(IntegrationWebSocketContainer webSocketContainer,
SubProtocolHandlerRegistry protocolHandlerRegistry) {
Assert.notNull(webSocketContainer, "'webSocketContainer' must not be null");
Assert.notNull(protocolHandlerRegistry, "'protocolHandlerRegistry' must not be null");
this.webSocketContainer = webSocketContainer;
@@ -128,7 +129,8 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
}
catch (Exception e) {
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(message,
() -> "Failed to handle and process message.", e);
() -> "Failed to handle and process message in the ["
+ WebSocketInboundChannelAdapter.this + ']', e);
}
});
}
@@ -241,6 +243,7 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
@Override
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus)
throws Exception { // NOSONAR Thrown from the delegate
if (isActive()) {
this.subProtocolHandlerRegistry.findProtocolHandler(session)
.afterSessionEnded(session, closeStatus, this.subProtocolHandlerChannel);
@@ -250,6 +253,7 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
@Override
public void onMessage(WebSocketSession session, WebSocketMessage<?> webSocketMessage)
throws Exception { // NOSONAR Thrown from the delegate
if (isActive()) {
this.subProtocolHandlerRegistry.findProtocolHandler(session)
.handleMessageFromClient(session, webSocketMessage, this.subProtocolHandlerChannel);
@@ -350,7 +354,7 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
}
catch (Exception e) {
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(message,
() -> "Error sending connect ack message", e);
() -> "Error sending connect ack message in the [" + this + ']', e);
}
}

View File

@@ -71,9 +71,9 @@ public class WebSocketOutboundMessageHandler extends AbstractMessageHandler {
private final boolean client;
private volatile List<MessageConverter> messageConverters;
private List<MessageConverter> messageConverters;
private volatile boolean mergeWithDefaultConverters = false;
private boolean mergeWithDefaultConverters = false;
public WebSocketOutboundMessageHandler(IntegrationWebSocketContainer webSocketContainer) {
this(webSocketContainer, new SubProtocolHandlerRegistry(new PassThruSubProtocolHandler()));
@@ -168,7 +168,7 @@ public class WebSocketOutboundMessageHandler extends AbstractMessageHandler {
}
}
catch (Exception e) {
throw new MessageHandlingException(message, "Failed to handle", e);
throw new MessageHandlingException(message, "Failed to handle message in the [" + this + ']', e);
}
}