Sonar fixes according latest report (#2676)

* Sonar fixes according latest report

* Fix initialization order in the `GatewayMethodInboundMessageMapper`

* Fix mock in the `DelegatingSessionFactoryTests`

* Fix `AbstractRemoteFileOutboundGateway.listFilesInRemoteDir`

* * PR comments

* * Fix `AbstractRemoteFileOutboundGateway.listFilesInRemoteDir` complexity
This commit is contained in:
Artem Bilan
2018-12-22 11:57:35 -05:00
committed by Gary Russell
parent 1943c15afe
commit 81b4ea1bef
9 changed files with 207 additions and 157 deletions

View File

@@ -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<Registration> 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()) {

View File

@@ -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<Object[]>, 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<Object[]
this.globalHeaderExpressions = globalHeaderExpressions;
this.parameterList = getMethodParameterList(method);
this.payloadExpression = parsePayloadExpression(method);
if (mapper == null) {
this.argsMapper = new DefaultMethodArgsMessageMapper();
}
else {
this.argsMapper = mapper;
}
if (messageBuilderFactory == null) {
this.messageBuilderFactory = new DefaultMessageBuilderFactory();
}
else {
this.messageBuilderFactory = messageBuilderFactory;
}
if (mapper == null) {
this.argsMapper = new DefaultMethodArgsMessageMapper();
}
else {
this.argsMapper = mapper;
}
}
@@ -194,13 +195,11 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
try {
return this.argsMapper.toMessage(new MethodArgsHolder(this.method, arguments), headers);
}
catch (MessagingException e) { // NOSONAR fto avoid if..else
throw e;
}
catch (Exception e) {
if (e instanceof MessagingException) {
throw (MessagingException) e;
}
else {
throw new MessageMappingException("Failed to map arguments", e);
}
throw new MessageMappingException("Failed to map arguments: " + Arrays.toString(arguments), e);
}
}
@@ -235,8 +234,8 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
for (Entry<?, ?> 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<Object[]
public class DefaultMethodArgsMessageMapper implements MethodArgsMessageMapper {
private final MessageBuilderFactory messageBuilderFactory =
GatewayMethodInboundMessageMapper.this.messageBuilderFactory;
@Override
public Message<?> toMessage(MethodArgsHolder holder, @Nullable Map<String, Object> headers) {
Object messageOrPayload = null;
boolean foundPayloadAnnotation = false;
Object[] arguments = holder.getArgs();
EvaluationContext methodInvocationEvaluationContext = createMethodInvocationEvaluationContext(arguments);
headers =
Map<String, Object> headersToPopulate =
headers != null
? new HashMap<>(headers)
: new HashMap<>();
@@ -309,76 +311,114 @@ class GatewayMethodInboundMessageMapper implements InboundMessageMapper<Object[]
false);
if (annotation != null) {
if (annotation.annotationType().equals(Payload.class)) {
if (messageOrPayload != null) {
throwExceptionForMultipleMessageOrPayloadParameters(methodParameter);
}
String expression = (String) AnnotationUtils.getValue(annotation);
if (!StringUtils.hasText(expression)) {
messageOrPayload = argumentValue;
}
else {
messageOrPayload = evaluatePayloadExpression(expression, argumentValue);
}
messageOrPayload =
processPayloadAnnotation(messageOrPayload, argumentValue, methodParameter, annotation);
foundPayloadAnnotation = true;
}
else if (annotation.annotationType().equals(Header.class)) {
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 + "'");
}
headers.put(headerName, argumentValue);
processHeaderAnnotation(headersToPopulate, argumentValue, methodParameter, annotation);
}
else if (annotation.annotationType().equals(Headers.class)) {
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);
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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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)) {

View File

@@ -743,13 +743,13 @@ public abstract class AbstractRemoteFileOutboundGateway<F> 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<F> extends AbstractReply
private List<F> listFilesInRemoteDir(Session<F> session, String directory, String subDirectory)
throws IOException {
List<F> lsFiles = new ArrayList<F>();
List<F> 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<F> 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<F> extends AbstractReply
return (this.filter != null) ? this.filter.filterFiles(files) : Arrays.asList(files);
}
private void processFile(Session<F> session, String directory, String subDirectory, List<F> 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<File> filterMputFiles(File[] files) {
if (files == null) {
return Collections.emptyList();
@@ -1009,7 +1014,8 @@ public abstract class AbstractRemoteFileOutboundGateway<F> 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<F> extends AbstractReply
}
try {
for (AbstractFileInfo<F> 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);
}

View File

@@ -421,13 +421,12 @@ public class RemoteFileOutboundGatewayTests {
@SuppressWarnings("unchecked")
MessageBuilder<List<TestLsEntry>> out = (MessageBuilder<List<TestLsEntry>>) 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));
}

View File

@@ -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<String>("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<String> dsf() {
SessionFactoryLocator<String> sff = sessionFactoryLocator();
return new DelegatingSessionFactory<String>(sff);
return new DelegatingSessionFactory<>(sff);
}
@Bean
public SessionFactoryLocator<String> sessionFactoryLocator() {
Map<Object, SessionFactory<String>> factories = new HashMap<Object, SessionFactory<String>>();
Map<Object, SessionFactory<String>> factories = new HashMap<>();
factories.put("foo", foo());
TestSessionFactory bar = bar();
factories.put("bar", bar);
SessionFactoryLocator<String> sff = new DefaultSessionFactoryLocator<String>(factories, bar);
return sff;
return new DefaultSessionFactoryLocator<>(factories, bar);
}
@ServiceActivator(inputChannel = "c1")
@Bean
MessageHandler handler() {
AbstractRemoteFileOutboundGateway<String> gateway = new AbstractRemoteFileOutboundGateway<String>(dsf(), "ls", "payload") {
AbstractRemoteFileOutboundGateway<String> gateway =
new AbstractRemoteFileOutboundGateway<String>(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<String> file) {
return file.getFilename();
}
@Override
protected String getFilename(AbstractFileInfo<String> file) {
return file.getFilename();
}
@Override
protected long getModified(String file) {
return 0;
}
@Override
protected long getModified(String file) {
return 0;
}
@Override
protected List<AbstractFileInfo<String>> asFileInfoList(Collection<String> files) {
return null;
}
@Override
protected List<AbstractFileInfo<String>> asFileInfoList(Collection<String> 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;

View File

@@ -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;

View File

@@ -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

View File

@@ -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<String, SubProtocolHandler> protocolHandlers = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
@@ -69,8 +69,8 @@ public final class SubProtocolHandlerRegistry {
for (SubProtocolHandler handler : protocolHandlers) {
List<String> 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<String> getSubProtocols() {
return new ArrayList<String>(this.protocolHandlers.keySet());
return new ArrayList<>(this.protocolHandlers.keySet());
}
}

View File

@@ -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
}