diff --git a/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/AbstractKryoRegistrar.java b/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/AbstractKryoRegistrar.java index c381552594..b1fecea480 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/AbstractKryoRegistrar.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/codec/kryo/AbstractKryoRegistrar.java @@ -16,8 +16,6 @@ package org.springframework.integration.codec.kryo; -import java.util.List; - import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -34,9 +32,9 @@ import com.esotericsoftware.kryo.Registration; */ public abstract class AbstractKryoRegistrar implements KryoRegistrar { - protected static final Kryo kryo = new Kryo(); + protected static final Kryo kryo = new Kryo(); // NOSONAR TODO uppercase in 5.2 - protected final Log log = LogFactory.getLog(this.getClass()); + protected final Log log = LogFactory.getLog(getClass()); @Override public void registerTypes(Kryo kryo) { @@ -45,19 +43,13 @@ public abstract class AbstractKryoRegistrar implements KryoRegistrar { } } - /** - * Subclasses implement this to get provided registrations. - * @return a list of {@link Registration} - */ - public abstract List getRegistrations(); - private void register(Kryo kryo, Registration registration) { int id = registration.getId(); Registration existing = kryo.getRegistration(id); if (existing != null) { - throw new RuntimeException("registration already exists " + existing); + throw new IllegalStateException("registration already exists " + existing); } if (this.log.isInfoEnabled()) { diff --git a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java index e4e7fbd540..2fad88a215 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/gateway/GatewayMethodInboundMessageMapper.java @@ -18,6 +18,7 @@ package org.springframework.integration.gateway; import java.lang.annotation.Annotation; import java.lang.reflect.Method; +import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.List; @@ -84,7 +85,7 @@ import org.springframework.util.StringUtils; */ class GatewayMethodInboundMessageMapper implements InboundMessageMapper, BeanFactoryAware { - private static final Log logger = LogFactory.getLog(GatewayMethodInboundMessageMapper.class); + private static final Log LOGGER = LogFactory.getLog(GatewayMethodInboundMessageMapper.class); private static final SpelExpressionParser PARSER = new SpelExpressionParser(); @@ -145,18 +146,18 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper entry : argumentValue.entrySet()) { Object key = entry.getKey(); if (!(key instanceof String)) { - if (logger.isWarnEnabled()) { - logger.warn("Invalid header name [" + key + + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("Invalid header name [" + key + "], name type must be String. Skipping mapping of this header to MessageHeaders."); } } @@ -286,13 +285,16 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper toMessage(MethodArgsHolder holder, @Nullable Map headers) { Object messageOrPayload = null; boolean foundPayloadAnnotation = false; Object[] arguments = holder.getArgs(); EvaluationContext methodInvocationEvaluationContext = createMethodInvocationEvaluationContext(arguments); - headers = + Map headersToPopulate = headers != null ? new HashMap<>(headers) : new HashMap<>(); @@ -309,76 +311,114 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper) argumentValue).keySet()) { - Assert.isInstanceOf(String.class, key, "Invalid header name [" + key + - "], name type must be String."); - Object value = ((Map) argumentValue).get(key); - headers.put((String) key, value); - } - } + processHeadersAnnotation(headersToPopulate, argumentValue); } } else if (messageOrPayload == null) { messageOrPayload = argumentValue; } else if (Map.class.isAssignableFrom(methodParameter.getParameterType())) { - if (messageOrPayload instanceof Map && !foundPayloadAnnotation) { - if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) { - throw new MessagingException("Ambiguous method parameters; found more than one " + - "Map-typed parameter and neither one contains a @Payload annotation"); - } - } - GatewayMethodInboundMessageMapper.this.copyHeaders((Map) argumentValue, headers); + processMapArgument(messageOrPayload, foundPayloadAnnotation, headersToPopulate, + (Map) argumentValue); } else if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) { - GatewayMethodInboundMessageMapper.this - .throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); + throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); } } - Assert.isTrue(messageOrPayload != null, "unable to determine a Message or payload parameter on method [" - + GatewayMethodInboundMessageMapper.this.method + "]"); + + Assert.isTrue(messageOrPayload != null, + () -> "unable to determine a Message or payload parameter on method [" + + GatewayMethodInboundMessageMapper.this.method + "]"); + populateSendAndReplyTimeoutHeaders(methodInvocationEvaluationContext, headersToPopulate); + + return buildMessage(headersToPopulate, messageOrPayload, methodInvocationEvaluationContext); + } + + @Nullable + private Object processPayloadAnnotation(@Nullable Object messageOrPayload, + Object argumentValue, MethodParameter methodParameter, Annotation annotation) { + + if (messageOrPayload != null) { + throwExceptionForMultipleMessageOrPayloadParameters(methodParameter); + } + String expression = (String) AnnotationUtils.getValue(annotation); + if (!StringUtils.hasText(expression)) { + return argumentValue; + } + else { + return evaluatePayloadExpression(expression, argumentValue); + } + } + + private void processHeaderAnnotation(Map headersToPopulate, @Nullable Object argumentValue, + MethodParameter methodParameter, Annotation annotation) { + + String headerName = determineHeaderName(annotation, methodParameter); + if ((Boolean) AnnotationUtils.getValue(annotation, "required") // NOSONAR never null + && argumentValue == null) { + throw new IllegalArgumentException("Received null argument value for required header: '" + + headerName + "'"); + } + headersToPopulate.put(headerName, argumentValue); + } + + private void processHeadersAnnotation(Map headersToPopulate, @Nullable Object argumentValue) { + if (argumentValue != null) { + if (!(argumentValue instanceof Map)) { + throw new IllegalArgumentException( + "@Headers annotation is only valid for Map-typed parameters"); + } + for (Object key : ((Map) argumentValue).keySet()) { + Assert.isInstanceOf(String.class, key, "Invalid header name [" + key + + "], name type must be String."); + Object value = ((Map) argumentValue).get(key); + headersToPopulate.put((String) key, value); + } + } + } + + private void processMapArgument(Object messageOrPayload, boolean foundPayloadAnnotation, + Map headersToPopulate, Map argumentValue) { + + if (messageOrPayload instanceof Map && !foundPayloadAnnotation) { + if (GatewayMethodInboundMessageMapper.this.payloadExpression == null) { + throw new MessagingException("Ambiguous method parameters; found more than one " + + "Map-typed parameter and neither one contains a @Payload annotation"); + } + } + copyHeaders(argumentValue, headersToPopulate); + } + + private void populateSendAndReplyTimeoutHeaders(EvaluationContext methodInvocationEvaluationContext, + Map headersToPopulate) { + if (GatewayMethodInboundMessageMapper.this.sendTimeoutExpression != null) { - headers.computeIfAbsent(GenericMessagingTemplate.DEFAULT_SEND_TIMEOUT_HEADER, + headersToPopulate.computeIfAbsent(GenericMessagingTemplate.DEFAULT_SEND_TIMEOUT_HEADER, v -> GatewayMethodInboundMessageMapper.this.sendTimeoutExpression .getValue(methodInvocationEvaluationContext, Long.class)); } if (GatewayMethodInboundMessageMapper.this.replyTimeoutExpression != null) { - headers.computeIfAbsent(GenericMessagingTemplate.DEFAULT_RECEIVE_TIMEOUT_HEADER, + headersToPopulate.computeIfAbsent(GenericMessagingTemplate.DEFAULT_RECEIVE_TIMEOUT_HEADER, v -> GatewayMethodInboundMessageMapper.this.replyTimeoutExpression .getValue(methodInvocationEvaluationContext, Long.class)); } - MessageBuilderFactory messageBuilderFactory = GatewayMethodInboundMessageMapper.this.messageBuilderFactory; + } + + private Message buildMessage(Map headers, Object messageOrPayload, + EvaluationContext methodInvocationEvaluationContext) { + AbstractIntegrationMessageBuilder builder = (messageOrPayload instanceof Message) - ? messageBuilderFactory.fromMessage((Message) messageOrPayload) - : messageBuilderFactory.withPayload(messageOrPayload); + ? this.messageBuilderFactory.fromMessage((Message) messageOrPayload) + : this.messageBuilderFactory.withPayload(messageOrPayload); builder.copyHeadersIfAbsent(headers); // Explicit headers in XML override any @Header annotations... if (!CollectionUtils.isEmpty(GatewayMethodInboundMessageMapper.this.headerExpressions)) { diff --git a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java index 8c3da6ff9b..3afcd43fd6 100644 --- a/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java +++ b/spring-integration-file/src/main/java/org/springframework/integration/file/remote/gateway/AbstractRemoteFileOutboundGateway.java @@ -743,13 +743,13 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply catch (Exception e) { if (replies.size() > 0) { throw new PartialSuccessException(requestMessage, - "Partially successful 'mput' operation" + (subDirectory == null ? "" : (" on " + subDirectory)), - e, replies, filteredFiles); + "Partially successful 'mput' operation" + + (subDirectory == null ? "" : (" on " + subDirectory)), e, replies, filteredFiles); } else if (e instanceof PartialSuccessException) { throw new PartialSuccessException(requestMessage, - "Partially successful 'mput' operation" + (subDirectory == null ? "" : (" on " + subDirectory)), - e, replies, filteredFiles); + "Partially successful 'mput' operation" + + (subDirectory == null ? "" : (" on " + subDirectory)), e, replies, filteredFiles); } else { throw e; @@ -801,28 +801,15 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply private List listFilesInRemoteDir(Session session, String directory, String subDirectory) throws IOException { - List lsFiles = new ArrayList(); + List lsFiles = new ArrayList<>(); String remoteDirectory = buildRemotePath(directory, subDirectory); F[] files = session.list(remoteDirectory); boolean recursion = this.options.contains(Option.RECURSIVE); if (!ObjectUtils.isEmpty(files)) { - Collection filteredFiles = this.filterFiles(files); - for (F file : filteredFiles) { - String fileName = this.getFilename(file); + for (F file : filterFiles(files)) { if (file != null) { - if (this.options.contains(Option.SUBDIRS) || !this.isDirectory(file)) { - if (recursion && StringUtils.hasText(subDirectory)) { - lsFiles.add(enhanceNameWithSubDirectory(file, subDirectory)); - } - else { - lsFiles.add(file); - } - } - if (recursion && this.isDirectory(file) && !(".".equals(fileName)) && !("..".equals(fileName))) { - lsFiles.addAll(listFilesInRemoteDir(session, directory, subDirectory + fileName - + this.remoteFileTemplate.getRemoteFileSeparator())); - } + processFile(session, directory, subDirectory, lsFiles, recursion, file); } } } @@ -844,6 +831,24 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply return (this.filter != null) ? this.filter.filterFiles(files) : Arrays.asList(files); } + private void processFile(Session session, String directory, String subDirectory, List lsFiles, + boolean recursion, F file) throws IOException { + + if (this.options.contains(Option.SUBDIRS) || !isDirectory(file)) { + if (recursion && StringUtils.hasText(subDirectory)) { + lsFiles.add(enhanceNameWithSubDirectory(file, subDirectory)); + } + else { + lsFiles.add(file); + } + } + String fileName = getFilename(file); + if (recursion && isDirectory(file) && !(".".equals(fileName)) && !("..".equals(fileName))) { + lsFiles.addAll(listFilesInRemoteDir(session, directory, + subDirectory + fileName + this.remoteFileTemplate.getRemoteFileSeparator())); + } + } + protected final List filterMputFiles(File[] files) { if (files == null) { return Collections.emptyList(); @@ -1009,7 +1014,8 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply */ String fileName = this.getRemoteFilename(fullFileName); String actualRemoteDirectory = this.getRemoteDirectory(fullFileName, fileName); - File file = get(message, session, actualRemoteDirectory, fullFileName, fileName, lsEntry.getFileInfo()); + File file = get(message, session, actualRemoteDirectory, fullFileName, fileName, + lsEntry.getFileInfo()); if (file != null) { files.add(file); } @@ -1044,16 +1050,18 @@ public abstract class AbstractRemoteFileOutboundGateway extends AbstractReply } try { for (AbstractFileInfo lsEntry : fileNames) { - String fullFileName = remoteDirectory != null - ? remoteDirectory + getFilename(lsEntry) - : getFilename(lsEntry); + String fullFileName = + remoteDirectory != null + ? remoteDirectory + getFilename(lsEntry) + : getFilename(lsEntry); /* * With recursion, the filename might contain subdirectory information * normalize each file separately. */ String fileName = this.getRemoteFilename(fullFileName); String actualRemoteDirectory = this.getRemoteDirectory(fullFileName, fileName); - File file = get(message, session, actualRemoteDirectory, fullFileName, fileName, lsEntry.getFileInfo()); + File file = get(message, session, actualRemoteDirectory, fullFileName, fileName, + lsEntry.getFileInfo()); if (file != null) { files.add(file); } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java index eca585f068..46c980bf57 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/gateway/RemoteFileOutboundGatewayTests.java @@ -421,13 +421,12 @@ public class RemoteFileOutboundGatewayTests { @SuppressWarnings("unchecked") MessageBuilder> out = (MessageBuilder>) gw .handleRequestMessage(new GenericMessage<>("testremote/x")); - assertEquals(6, out.getPayload().size()); + assertEquals(5, out.getPayload().size()); assertEquals("f1", out.getPayload().get(0).getFilename()); assertEquals("d1", out.getPayload().get(1).getFilename()); assertEquals("d1/d2", out.getPayload().get(2).getFilename()); - assertEquals("d1/d2/f4", out.getPayload().get(3).getFilename()); - assertEquals("d1/f3", out.getPayload().get(4).getFilename()); - assertEquals("f2", out.getPayload().get(5).getFilename()); + assertEquals("d1/f3", out.getPayload().get(3).getFilename()); + assertEquals("f2", out.getPayload().get(4).getFilename()); assertEquals("testremote/x/", out.getHeaders().get(FileHeaders.REMOTE_DIRECTORY)); } diff --git a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java index 185c7c24ae..a77df1bca3 100644 --- a/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java +++ b/spring-integration-file/src/test/java/org/springframework/integration/file/remote/session/DelegatingSessionFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016 the original author or authors. + * Copyright 2015-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.BDDMockito.given; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -50,6 +52,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /** * @author Gary Russell + * @author Artem Bilan + * * @since 4.2 * */ @@ -94,7 +98,9 @@ public class DelegatingSessionFactoryTests { @Test public void testFlow() throws Exception { - in.send(new GenericMessage("foo")); + given(foo.mockSession.list(anyString())) + .willReturn(new String[0]); + in.send(new GenericMessage<>("foo")); Message received = out.receive(0); assertNotNull(received); verify(foo.mockSession).list("foo/"); @@ -102,7 +108,8 @@ public class DelegatingSessionFactoryTests { } @Configuration - @ImportResource("classpath:/org/springframework/integration/file/remote/session/delegating-session-factory-context.xml") + @ImportResource( + "classpath:/org/springframework/integration/file/remote/session/delegating-session-factory-context.xml") @EnableIntegration public static class Config { @@ -119,59 +126,59 @@ public class DelegatingSessionFactoryTests { @Bean DelegatingSessionFactory dsf() { SessionFactoryLocator sff = sessionFactoryLocator(); - return new DelegatingSessionFactory(sff); + return new DelegatingSessionFactory<>(sff); } @Bean public SessionFactoryLocator sessionFactoryLocator() { - Map> factories = new HashMap>(); + Map> factories = new HashMap<>(); factories.put("foo", foo()); TestSessionFactory bar = bar(); factories.put("bar", bar); - SessionFactoryLocator sff = new DefaultSessionFactoryLocator(factories, bar); - return sff; + return new DefaultSessionFactoryLocator<>(factories, bar); } @ServiceActivator(inputChannel = "c1") @Bean MessageHandler handler() { - AbstractRemoteFileOutboundGateway gateway = new AbstractRemoteFileOutboundGateway(dsf(), "ls", "payload") { + AbstractRemoteFileOutboundGateway gateway = + new AbstractRemoteFileOutboundGateway(dsf(), "ls", "payload") { - @Override - protected boolean isDirectory(String file) { - return false; - } + @Override + protected boolean isDirectory(String file) { + return false; + } - @Override - protected boolean isLink(String file) { - return false; - } + @Override + protected boolean isLink(String file) { + return false; + } - @Override - protected String getFilename(String file) { - return file; - } + @Override + protected String getFilename(String file) { + return file; + } - @Override - protected String getFilename(AbstractFileInfo file) { - return file.getFilename(); - } + @Override + protected String getFilename(AbstractFileInfo file) { + return file.getFilename(); + } - @Override - protected long getModified(String file) { - return 0; - } + @Override + protected long getModified(String file) { + return 0; + } - @Override - protected List> asFileInfoList(Collection files) { - return null; - } + @Override + protected List> asFileInfoList(Collection files) { + return null; + } - @Override - protected String enhanceNameWithSubDirectory(String file, String directory) { - return null; - } - }; + @Override + protected String enhanceNameWithSubDirectory(String file, String directory) { + return null; + } + }; gateway.setOutputChannelName("c2"); gateway.setOptions("-1"); return gateway; diff --git a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java index 574d1e177e..6b4450d198 100644 --- a/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java +++ b/spring-integration-sftp/src/main/java/org/springframework/integration/sftp/session/JschLogger.java @@ -29,20 +29,20 @@ import com.jcraft.jsch.Logger; */ class JschLogger implements Logger { - private static final Log logger = LogFactory.getLog("com.jcraft.jsch"); + private static final Log LOGGER = LogFactory.getLog("com.jcraft.jsch"); public boolean isEnabled(int level) { switch (level) { case Logger.INFO: - return logger.isInfoEnabled(); + return LOGGER.isInfoEnabled(); case Logger.WARN: - return logger.isWarnEnabled(); + return LOGGER.isWarnEnabled(); case Logger.DEBUG: - return logger.isDebugEnabled(); + return LOGGER.isDebugEnabled(); case Logger.ERROR: - return logger.isErrorEnabled(); + return LOGGER.isErrorEnabled(); case Logger.FATAL: - return logger.isFatalEnabled(); + return LOGGER.isFatalEnabled(); default: return false; } @@ -51,19 +51,19 @@ class JschLogger implements Logger { public void log(int level, String message) { switch (level) { case Logger.INFO: - logger.info(message); + LOGGER.info(message); break; case Logger.WARN: - logger.warn(message); + LOGGER.warn(message); break; case Logger.DEBUG: - logger.debug(message); + LOGGER.debug(message); break; case Logger.ERROR: - logger.error(message); + LOGGER.error(message); break; case Logger.FATAL: - logger.fatal(message); + LOGGER.fatal(message); break; default: break; diff --git a/spring-integration-test-support/src/main/java/org/springframework/integration/test/support/LongRunningIntegrationTest.java b/spring-integration-test-support/src/main/java/org/springframework/integration/test/support/LongRunningIntegrationTest.java index f2fe923cc5..f4448f658a 100644 --- a/spring-integration-test-support/src/main/java/org/springframework/integration/test/support/LongRunningIntegrationTest.java +++ b/spring-integration-test-support/src/main/java/org/springframework/integration/test/support/LongRunningIntegrationTest.java @@ -35,7 +35,7 @@ import org.junit.runners.model.Statement; */ public class LongRunningIntegrationTest extends TestWatcher { - private static final Log logger = LogFactory.getLog(LongRunningIntegrationTest.class); + private static final Log LOGGER = LogFactory.getLog(LongRunningIntegrationTest.class); private static final String RUN_LONG_PROP = "RUN_LONG_INTEGRATION_TESTS"; @@ -53,7 +53,7 @@ public class LongRunningIntegrationTest extends TestWatcher { @Override public Statement apply(Statement base, Description description) { if (!this.shouldRun) { - logger.info("Skipping long running test " + description.getDisplayName()); + LOGGER.info("Skipping long running test " + description.getDisplayName()); return new Statement() { @Override diff --git a/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/support/SubProtocolHandlerRegistry.java b/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/support/SubProtocolHandlerRegistry.java index 58b49c1906..0b060f5bff 100644 --- a/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/support/SubProtocolHandlerRegistry.java +++ b/spring-integration-websocket/src/main/java/org/springframework/integration/websocket/support/SubProtocolHandlerRegistry.java @@ -46,7 +46,7 @@ import org.springframework.web.socket.messaging.SubProtocolHandler; */ public final class SubProtocolHandlerRegistry { - private static final Log logger = LogFactory.getLog(SubProtocolHandlerRegistry.class); + private static final Log LOGGER = LogFactory.getLog(SubProtocolHandlerRegistry.class); private final Map protocolHandlers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); @@ -69,8 +69,8 @@ public final class SubProtocolHandlerRegistry { for (SubProtocolHandler handler : protocolHandlers) { List protocols = handler.getSupportedProtocols(); if (CollectionUtils.isEmpty(protocols)) { - if (logger.isWarnEnabled()) { - logger.warn("No sub-protocols, ignoring handler " + handler); + if (LOGGER.isWarnEnabled()) { + LOGGER.warn("No sub-protocols, ignoring handler " + handler); } continue; } @@ -153,7 +153,7 @@ public final class SubProtocolHandlerRegistry { * @return The the {@link List} of supported sub-protocols. */ public List getSubProtocols() { - return new ArrayList(this.protocolHandlers.keySet()); + return new ArrayList<>(this.protocolHandlers.keySet()); } } diff --git a/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceInboundGateway.java b/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceInboundGateway.java index 36c7dead8d..f3cf880c42 100644 --- a/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceInboundGateway.java +++ b/spring-integration-ws/src/main/java/org/springframework/integration/ws/AbstractWebServiceInboundGateway.java @@ -43,7 +43,7 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS private final AtomicInteger activeCount = new AtomicInteger(); - protected SoapHeaderMapper headerMapper = new DefaultSoapHeaderMapper(); + private SoapHeaderMapper headerMapper = new DefaultSoapHeaderMapper(); @Override public String getComponentType() { @@ -55,6 +55,10 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS this.headerMapper = headerMapper; } + protected SoapHeaderMapper getHeaderMapper() { + return this.headerMapper; + } + public void invoke(MessageContext messageContext) throws Exception { if (!isRunning()) { throw new ServiceUnavailableException("503 Service Unavailable"); @@ -112,6 +116,6 @@ public abstract class AbstractWebServiceInboundGateway extends MessagingGatewayS return this.activeCount.get(); } - protected abstract void doInvoke(MessageContext messageContext) throws Exception; + protected abstract void doInvoke(MessageContext messageContext) throws Exception; // NOSONAR any exception }