Lambdas for Remaining Modules JPA -> ZK

Polishing - PR Comments and Closeable Warnings

Eclipse emits bogus warnings with exceptions in lambdas.
Even though the lambda might run on another thread, elipse thinks it could
cause the context to not be closed.

SPR-14854: MessageChannel is now a @FunctionalInterface

* Additional Lambda polishing and some code style fixes
This commit is contained in:
Gary Russell
2016-10-28 12:07:06 -04:00
committed by Artem Bilan
parent 16be9fc47d
commit 67d6cd0c89
83 changed files with 870 additions and 1324 deletions

View File

@@ -204,7 +204,7 @@ public final class ClientWebSocketContainer extends IntegrationWebSocketContaine
private final boolean syncClientLifecycle;
private IntegrationWebSocketConnectionManager(WebSocketClient client, String uriTemplate,
IntegrationWebSocketConnectionManager(WebSocketClient client, String uriTemplate,
Object... uriVariables) {
super(uriTemplate, uriVariables);
this.client = client;

View File

@@ -148,6 +148,10 @@ public abstract class IntegrationWebSocketContainer implements DisposableBean {
*/
private class IntegrationWebSocketHandler implements WebSocketHandler, SubProtocolCapable {
IntegrationWebSocketHandler() {
super();
}
@Override
public List<String> getSubProtocols() {
return IntegrationWebSocketContainer.this.getSubProtocols();

View File

@@ -37,9 +37,7 @@ import org.springframework.integration.websocket.support.PassThruSubProtocolHand
import org.springframework.integration.websocket.support.SubProtocolHandlerRegistry;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessagingException;
import org.springframework.messaging.converter.ByteArrayMessageConverter;
import org.springframework.messaging.converter.CompositeMessageConverter;
import org.springframework.messaging.converter.DefaultContentTypeResolver;
@@ -119,18 +117,13 @@ public class WebSocketInboundChannelAdapter extends MessageProducerSupport
this.webSocketContainer = webSocketContainer;
this.server = this.webSocketContainer instanceof ServerWebSocketContainer;
this.subProtocolHandlerRegistry = protocolHandlerRegistry;
this.subProtocolHandlerChannel = new FixedSubscriberChannel(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
try {
handleMessageAndSend(message);
}
catch (Exception e) {
throw new MessageHandlingException(message, e);
}
this.subProtocolHandlerChannel = new FixedSubscriberChannel(message -> {
try {
handleMessageAndSend(message);
}
catch (Exception e) {
throw new MessageHandlingException(message, e);
}
});
}

View File

@@ -489,23 +489,17 @@ public class StompIntegrationTests extends LogAdjustingTestSupport {
//TODO SimpleBrokerMessageHandler doesn't support RECEIPT frame, hence we emulate it this way
@Bean
@SuppressWarnings("unchecked")
public ApplicationListener<SessionSubscribeEvent> webSocketEventListener(
final AbstractSubscribableChannel clientOutboundChannel) {
return new ApplicationListener<SessionSubscribeEvent>() {
@Override
public void onApplicationEvent(SessionSubscribeEvent event) {
Message<byte[]> message = event.getMessage();
StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(message);
if (stompHeaderAccessor.getReceipt() != null) {
stompHeaderAccessor.setHeader("stompCommand", StompCommand.RECEIPT);
stompHeaderAccessor.setReceiptId(stompHeaderAccessor.getReceipt());
clientOutboundChannel.send(
MessageBuilder.createMessage(new byte[0], stompHeaderAccessor.getMessageHeaders()));
}
return event -> {
Message<byte[]> message = event.getMessage();
StompHeaderAccessor stompHeaderAccessor = StompHeaderAccessor.wrap(message);
if (stompHeaderAccessor.getReceipt() != null) {
stompHeaderAccessor.setHeader("stompCommand", StompCommand.RECEIPT);
stompHeaderAccessor.setReceiptId(stompHeaderAccessor.getReceipt());
clientOutboundChannel.send(
MessageBuilder.createMessage(new byte[0], stompHeaderAccessor.getMessageHeaders()));
}
};
}

View File

@@ -318,6 +318,10 @@ public class WebSocketServerTests {
private ApplicationEventPublisher applicationEventPublisher;
TestWebSocketHandlerDecoratorFactory() {
super();
}
@Override
public WebSocketHandler decorate(WebSocketHandler handler) {
return new TestWebSocketHandler(handler);