Sonar fixes
- a few complexities - final method calls from ctor - raw exception throwing - useless overrides - loss of stack trace
This commit is contained in:
committed by
Artem Bilan
parent
7569d0ad79
commit
36c33bb5ab
@@ -52,7 +52,7 @@ public abstract class AbstractMessageListenerContainerSpec<S extends AbstractMes
|
||||
}
|
||||
|
||||
@Override
|
||||
public S id(String id) {
|
||||
public S id(String id) { // NOSONAR - not useless, increases visibility
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ public class GlobalChannelInterceptorWrapper implements Ordered {
|
||||
|
||||
private final ChannelInterceptor channelInterceptor;
|
||||
|
||||
private volatile String[] patterns = new String[]{"*"}; // default
|
||||
private volatile String[] patterns = { "*" }; // default
|
||||
|
||||
private volatile int order = 0;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class GlobalChannelInterceptorWrapper implements Ordered {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
public final int getOrder() {
|
||||
return this.order;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ public class CompositeKryoRegistrar extends AbstractKryoRegistrar {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Registration> getRegistrations() {
|
||||
public final List<Registration> getRegistrations() {
|
||||
List<Registration> registrations = new ArrayList<Registration>();
|
||||
for (KryoRegistrar registrar : this.delegates) {
|
||||
registrations.addAll(registrar.getRegistrations());
|
||||
@@ -59,13 +59,13 @@ public class CompositeKryoRegistrar extends AbstractKryoRegistrar {
|
||||
Assert.isTrue(registration.getId() >= MIN_REGISTRATION_VALUE,
|
||||
"registration ID must be >= " + MIN_REGISTRATION_VALUE);
|
||||
if (ids.contains(registration.getId())) {
|
||||
throw new RuntimeException(String.format("Duplicate registration ID found: %d",
|
||||
throw new IllegalArgumentException(String.format("Duplicate registration ID found: %d",
|
||||
registration.getId()));
|
||||
}
|
||||
ids.add(registration.getId());
|
||||
|
||||
if (types.contains(registration.getType())) {
|
||||
throw new RuntimeException(String.format("Duplicate registration found for type: %s",
|
||||
throw new IllegalArgumentException(String.format("Duplicate registration found for type: %s",
|
||||
registration.getType()));
|
||||
}
|
||||
types.add(registration.getType());
|
||||
|
||||
@@ -94,6 +94,12 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
|
||||
router.setIgnoreSendFailures(resolveAttributeToBoolean(ignoreSendFailures));
|
||||
}
|
||||
|
||||
routerAttributes(annotations, router);
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
private void routerAttributes(List<Annotation> annotations, AbstractMessageRouter router) {
|
||||
if (routerAttributesProvided(annotations)) {
|
||||
|
||||
MethodInvokingRouter methodInvokingRouter = (MethodInvokingRouter) router;
|
||||
@@ -127,8 +133,6 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return router;
|
||||
}
|
||||
|
||||
private boolean routerAttributesProvided(List<Annotation> annotations) {
|
||||
|
||||
@@ -144,27 +144,7 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
|
||||
String inputChannelName = element.getAttribute(inputChannelAttributeName);
|
||||
|
||||
if (!parserContext.getRegistry().containsBeanDefinition(inputChannelName)) {
|
||||
if (parserContext.getRegistry()
|
||||
.containsBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME)) {
|
||||
|
||||
BeanDefinition channelRegistry = parserContext.getRegistry().
|
||||
getBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME);
|
||||
ConstructorArgumentValues caValues = channelRegistry.getConstructorArgumentValues();
|
||||
ValueHolder vh = caValues.getArgumentValue(0, Collection.class);
|
||||
if (vh == null) { //although it should never happen if it does we can fix it
|
||||
caValues.addIndexedArgumentValue(0, new ManagedSet<String>());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<String> channelCandidateNames =
|
||||
(Collection<String>) caValues.getArgumentValue(0, Collection.class).getValue(); // NOSONAR see comment above
|
||||
channelCandidateNames.add(inputChannelName); // NOSONAR
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("Failed to locate '" +
|
||||
IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME + "'",
|
||||
parserContext.getRegistry());
|
||||
}
|
||||
registerChannelForCreation(parserContext, inputChannelName);
|
||||
}
|
||||
IntegrationNamespaceUtils.checkAndConfigureFixedSubscriberChannel(element, parserContext, inputChannelName,
|
||||
handlerBeanName);
|
||||
@@ -188,6 +168,30 @@ public abstract class AbstractConsumerEndpointParser extends AbstractBeanDefinit
|
||||
return null;
|
||||
}
|
||||
|
||||
private void registerChannelForCreation(ParserContext parserContext, String inputChannelName) {
|
||||
if (parserContext.getRegistry()
|
||||
.containsBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME)) {
|
||||
|
||||
BeanDefinition channelRegistry = parserContext.getRegistry().
|
||||
getBeanDefinition(IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME);
|
||||
ConstructorArgumentValues caValues = channelRegistry.getConstructorArgumentValues();
|
||||
ValueHolder vh = caValues.getArgumentValue(0, Collection.class);
|
||||
if (vh == null) { //although it should never happen if it does we can fix it
|
||||
caValues.addIndexedArgumentValue(0, new ManagedSet<String>());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<String> channelCandidateNames =
|
||||
(Collection<String>) caValues.getArgumentValue(0, Collection.class).getValue(); // NOSONAR see comment above
|
||||
channelCandidateNames.add(inputChannelName); // NOSONAR
|
||||
}
|
||||
else {
|
||||
parserContext.getReaderContext().error("Failed to locate '" +
|
||||
IntegrationContextUtils.AUTO_CREATE_CHANNEL_CANDIDATES_BEAN_NAME + "'",
|
||||
parserContext.getRegistry());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override to allow 'reply-channel' within a chain, for components where it
|
||||
* makes sense (e.g. enricher). Default is false for outbound gateways, else true.
|
||||
|
||||
@@ -101,6 +101,17 @@ abstract class AbstractDelegatingConsumerEndpointParser extends AbstractConsumer
|
||||
IntegrationNamespaceUtils.createElementDescription(element) + ".", source);
|
||||
return null;
|
||||
}
|
||||
methodAttribute(element, parserContext, source, builder, innerDefinition, hasRef, hasExpression,
|
||||
expressionElement);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
|
||||
this.postProcess(builder, element, parserContext);
|
||||
return builder;
|
||||
}
|
||||
|
||||
private void methodAttribute(Element element, ParserContext parserContext, Object source,
|
||||
BeanDefinitionBuilder builder, BeanComponentDefinition innerDefinition, boolean hasRef,
|
||||
boolean hasExpression, Element expressionElement) {
|
||||
String method = element.getAttribute(METHOD_ATTRIBUTE);
|
||||
if (StringUtils.hasText(method)) {
|
||||
if (hasExpression || expressionElement != null) {
|
||||
@@ -117,10 +128,6 @@ abstract class AbstractDelegatingConsumerEndpointParser extends AbstractConsumer
|
||||
IntegrationNamespaceUtils.createElementDescription(element) + ".", source);
|
||||
}
|
||||
}
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "requires-reply");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "send-timeout");
|
||||
this.postProcess(builder, element, parserContext);
|
||||
return builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,9 +16,6 @@
|
||||
|
||||
package org.springframework.integration.dsl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.AbstractFactoryBean;
|
||||
@@ -42,8 +39,6 @@ public abstract class IntegrationComponentSpec<S extends IntegrationComponentSpe
|
||||
|
||||
protected static final SpelExpressionParser PARSER = new SpelExpressionParser();
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR
|
||||
|
||||
protected volatile T target; // NOSONAR
|
||||
|
||||
private String id;
|
||||
@@ -51,11 +46,11 @@ public abstract class IntegrationComponentSpec<S extends IntegrationComponentSpe
|
||||
/**
|
||||
* Configure the component identifier. Used as the {@code beanName} to register the
|
||||
* bean in the application context for this component.
|
||||
* @param id the id.
|
||||
* @param idToSet the id.
|
||||
* @return the spec.
|
||||
*/
|
||||
protected S id(String id) {
|
||||
this.id = id;
|
||||
protected S id(String idToSet) {
|
||||
this.id = idToSet;
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public final class IntegrationFlowBuilder extends IntegrationFlowDefinition<Inte
|
||||
}
|
||||
|
||||
@Override
|
||||
public StandardIntegrationFlow get() {
|
||||
public StandardIntegrationFlow get() { // NOSONAR - not useless, increases visibility
|
||||
return super.get();
|
||||
}
|
||||
|
||||
|
||||
@@ -57,22 +57,17 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected S id(String id) {
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
public S datatype(Class<?>... datatypes) {
|
||||
Assert.notNull(datatypes, "'datatypes' must not be null");
|
||||
Assert.noNullElements(datatypes, "'datatypes' must not contain null elements");
|
||||
this.datatypes.addAll(Arrays.asList(datatypes));
|
||||
public S datatype(Class<?>... types) {
|
||||
Assert.notNull(types, "'datatypes' must not be null");
|
||||
Assert.noNullElements(types, "'datatypes' must not contain null elements");
|
||||
this.datatypes.addAll(Arrays.asList(types));
|
||||
return _this();
|
||||
}
|
||||
|
||||
public S interceptor(ChannelInterceptor... interceptors) {
|
||||
Assert.notNull(interceptors, "'interceptors' must not be null");
|
||||
Assert.noNullElements(interceptors, "'interceptors' must not contain null elements");
|
||||
this.interceptors.addAll(Arrays.asList(interceptors));
|
||||
public S interceptor(ChannelInterceptor... interceptorArray) {
|
||||
Assert.notNull(interceptorArray, "'interceptorArray' must not be null");
|
||||
Assert.noNullElements(interceptorArray, "'interceptorArray' must not contain null elements");
|
||||
this.interceptors.addAll(Arrays.asList(interceptorArray));
|
||||
return _this();
|
||||
}
|
||||
|
||||
@@ -111,8 +106,8 @@ public abstract class MessageChannelSpec<S extends MessageChannelSpec<S, C>, C e
|
||||
return interceptor(interceptor);
|
||||
}
|
||||
|
||||
public S messageConverter(MessageConverter messageConverter) {
|
||||
this.messageConverter = messageConverter;
|
||||
public S messageConverter(MessageConverter converter) {
|
||||
this.messageConverter = converter;
|
||||
return _this();
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PublishSubscribeSpec extends PublishSubscribeChannelSpec<PublishSub
|
||||
}
|
||||
|
||||
@Override
|
||||
public PublishSubscribeSpec id(String id) {
|
||||
public PublishSubscribeSpec id(String id) { // NOSONAR - not useless, increases visibility
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ public class FunctionExpression<S> implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
public final String getExpressionString() {
|
||||
return this.function.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ public class SupplierExpression<T> implements Expression {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExpressionString() {
|
||||
public final String getExpressionString() {
|
||||
return this.supplier.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ public abstract class IntegrationNode {
|
||||
|
||||
private final int nodeId;
|
||||
|
||||
private final String name;
|
||||
private final String nodeName;
|
||||
|
||||
private final Stats stats;
|
||||
|
||||
@@ -51,7 +51,7 @@ public abstract class IntegrationNode {
|
||||
|
||||
protected IntegrationNode(int nodeId, String name, Object nodeObject, Stats stats) {
|
||||
this.nodeId = nodeId;
|
||||
this.name = name;
|
||||
this.nodeName = name;
|
||||
this.componentType =
|
||||
nodeObject instanceof NamedComponent
|
||||
? ((NamedComponent) nodeObject).getComponentType()
|
||||
@@ -70,10 +70,10 @@ public abstract class IntegrationNode {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
return this.nodeName;
|
||||
}
|
||||
|
||||
public String getComponentType() {
|
||||
public final String getComponentType() {
|
||||
return this.componentType;
|
||||
}
|
||||
|
||||
@@ -98,12 +98,12 @@ public abstract class IntegrationNode {
|
||||
|
||||
/**
|
||||
* Add extra property to the node.
|
||||
* @param properties additional properties to add
|
||||
* @param props additional properties to add
|
||||
* @since 5.1
|
||||
*/
|
||||
public void addProperties(@Nullable Map<String, Object> properties) {
|
||||
if (properties != null) {
|
||||
this.properties.putAll(properties);
|
||||
public void addProperties(@Nullable Map<String, Object> props) {
|
||||
if (props != null) {
|
||||
this.properties.putAll(props);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class LambdaMessageProcessor implements MessageProcessor<Object>, BeanFac
|
||||
"An example of when this often occurs is if the lambda is configured to " +
|
||||
"receive a Message<?> argument.", e.getCause());
|
||||
}
|
||||
throw new MessageHandlingException(message, e.getCause());
|
||||
throw new MessageHandlingException(message, e.getCause()); // NOSONAR lost stack trace
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(message,
|
||||
|
||||
@@ -84,10 +84,10 @@ public class LoggingHandler extends AbstractMessageHandler {
|
||||
try {
|
||||
return Level.valueOf(level.toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException e) {
|
||||
catch (@SuppressWarnings("unused") IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException("Invalid log level '" + level
|
||||
+ "'. The (case-insensitive) supported values are: "
|
||||
+ StringUtils.arrayToCommaDelimitedString(Level.values()));
|
||||
+ StringUtils.arrayToCommaDelimitedString(Level.values())); // NOSONAR lost stack trace
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class MutableMessageHeaders extends MessageHeaders {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Map<String, Object> getRawHeaders() {
|
||||
protected Map<String, Object> getRawHeaders() { // NOSONAR - not useless; increases visibility
|
||||
return super.getRawHeaders();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
public SmartLifecycleRoleController(List<String> roles, List<SmartLifecycle> lifecycles) {
|
||||
Assert.notNull(roles, "'roles' cannot be null");
|
||||
Assert.notNull(lifecycles, "'lifecycles' cannot be null");
|
||||
Assert.isTrue(roles.size() == lifecycles.size(), "'roles' and 'lifecycles' must be the same lenght");
|
||||
Assert.isTrue(roles.size() == lifecycles.size(), "'roles' and 'lifecycles' must be the same length");
|
||||
Iterator<SmartLifecycle> iterator = lifecycles.iterator();
|
||||
for (String role : roles) {
|
||||
SmartLifecycle lifecycle = iterator.next();
|
||||
@@ -134,7 +134,7 @@ public class SmartLifecycleRoleController implements ApplicationListener<Abstrac
|
||||
* @param role the role.
|
||||
* @param lifecycleBeanName the bean name of the {@link SmartLifecycle}.
|
||||
*/
|
||||
public void addLifecycleToRole(String role, String lifecycleBeanName) {
|
||||
public final void addLifecycleToRole(String role, String lifecycleBeanName) {
|
||||
Assert.state(this.applicationContext != null, "An application context is required to use this method");
|
||||
this.lazyLifecycles.add(role, lifecycleBeanName);
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public final class IntegrationUtils {
|
||||
logger.debug("No 'beanFactory' supplied; cannot find MessageBuilderFactory, using default.");
|
||||
}
|
||||
if (fatalWhenNoBeanFactory) {
|
||||
throw new RuntimeException("All Message creators need a BeanFactory");
|
||||
throw new IllegalStateException("All Message creators need a BeanFactory");
|
||||
}
|
||||
}
|
||||
if (messageBuilderFactory == null) {
|
||||
|
||||
@@ -488,7 +488,7 @@ public class ContentEnricher extends AbstractReplyProducingMessageHandler implem
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Message<?> sendAndReceiveMessage(Object object) {
|
||||
protected Message<?> sendAndReceiveMessage(Object object) { // NOSONAR - not useless, increases visibility
|
||||
return super.sendAndReceiveMessage(object);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.util.ClassUtils;
|
||||
* Utility to help generate UUID instances from generic objects.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class UUIDConverter implements Converter<Object, UUID> {
|
||||
|
||||
@@ -41,6 +42,7 @@ public class UUIDConverter implements Converter<Object, UUID> {
|
||||
*
|
||||
* @see org.springframework.core.convert.converter.Converter#convert(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public UUID convert(Object source) {
|
||||
return getUUID(source);
|
||||
}
|
||||
@@ -80,7 +82,10 @@ public class UUIDConverter implements Converter<Object, UUID> {
|
||||
return UUID.nameUUIDFromBytes(((String) input).getBytes(DEFAULT_CHARSET));
|
||||
}
|
||||
catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalStateException("Cannot convert String using charset=" + DEFAULT_CHARSET, ex);
|
||||
IllegalStateException exception =
|
||||
new IllegalStateException("Cannot convert String using charset=" + DEFAULT_CHARSET, ex);
|
||||
exception.addSuppressed(e);
|
||||
throw exception; // NOSONAR - added to suppressed exceptions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F>
|
||||
}
|
||||
|
||||
@Override
|
||||
protected AbstractIntegrationMessageBuilder<File> doReceive() {
|
||||
protected AbstractIntegrationMessageBuilder<File> doReceive() { // NOSONAR - not useless, increases visibility
|
||||
return super.doReceive();
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ public class DefaultFtpsSessionFactory extends AbstractFtpSessionFactory<FTPSCli
|
||||
throw (RuntimeException) e;
|
||||
}
|
||||
|
||||
throw new RuntimeException("Failed to create FTPS client.", e);
|
||||
throw new IllegalStateException("Failed to create FTPS client.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ public class IntegrationGraphControllerTests {
|
||||
|
||||
handlerAdapter.handle(request, response, handler);
|
||||
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
assertThat(response.getContentAsString()).contains("\"name\":\"nullChannel\",");
|
||||
assertThat(response.getContentAsString()).doesNotContain("\"name\":\"myChannel\",");
|
||||
assertThat(response.getContentAsString()).contains("\"name\":\"nullChannel\"");
|
||||
assertThat(response.getContentAsString()).doesNotContain("\"name\":\"myChannel\"");
|
||||
|
||||
context.getBeanFactory().registerSingleton("myChannel", new DirectChannel());
|
||||
|
||||
@@ -146,7 +146,7 @@ public class IntegrationGraphControllerTests {
|
||||
|
||||
handlerAdapter.handle(request, response, handler);
|
||||
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
|
||||
assertThat(response.getContentAsString()).contains("\"name\":\"myChannel\",");
|
||||
assertThat(response.getContentAsString()).contains("\"name\":\"myChannel\"");
|
||||
|
||||
context.close();
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class FailoverClientConnectionFactory extends AbstractClientConnectionFac
|
||||
* the real listener supplied here, with the modified message.
|
||||
*/
|
||||
@Override
|
||||
public void registerListener(TcpListener listener) {
|
||||
public void registerListener(TcpListener listener) { // NOSONAR - not useless, custom Javadoc
|
||||
super.registerListener(listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public abstract class TcpConnectionSupport implements TcpConnection {
|
||||
this.connectionFactoryName = connectionFactoryName;
|
||||
}
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("New connection " + this.getConnectionId());
|
||||
this.logger.debug("New connection " + this.connectionId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -358,9 +358,9 @@ public class TcpNioConnection extends TcpConnectionSupport {
|
||||
throw new IOException("Timed out waiting for IO");
|
||||
}
|
||||
}
|
||||
catch (@SuppressWarnings(UNUSED) InterruptedException e) {
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IOException("Interrupted waiting for IO");
|
||||
throw new IOException("Interrupted waiting for IO", e);
|
||||
}
|
||||
}
|
||||
Message<?> message = null;
|
||||
|
||||
@@ -421,7 +421,7 @@ public class TcpNioSSLConnection extends TcpNioConnection {
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new MessagingException("Interrupted during SSL Handshaking");
|
||||
throw new MessagingException("Interrupted during SSL Handshaking", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -502,12 +502,12 @@ public class ChannelPublishingJmsMessageListener
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void send(Object request) {
|
||||
protected void send(Object request) { // NOSONAR - not useless, increases visibility
|
||||
super.send(request);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Message<?> sendAndReceiveMessage(Object request) {
|
||||
protected Message<?> sendAndReceiveMessage(Object request) { // NOSONAR - not useless, increases visibility
|
||||
return super.sendAndReceiveMessage(request);
|
||||
}
|
||||
|
||||
|
||||
@@ -1337,7 +1337,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
debugLogger.debug("No pending reply for " + siMessage + " with correlationId: "
|
||||
+ correlnId + " pending replies: " + this.replies.keySet());
|
||||
}
|
||||
throw new RuntimeException("No sender waiting for reply");
|
||||
throw new IllegalStateException("No sender waiting for reply");
|
||||
}
|
||||
synchronized (this.earlyOrLateReplies) {
|
||||
queue = this.replies.get(correlnId);
|
||||
@@ -1410,9 +1410,9 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler imp
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
}
|
||||
catch (@SuppressWarnings("unused") InterruptedException e) {
|
||||
catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Container did not establish a destination");
|
||||
throw new IllegalStateException("Container did not establish a destination", e);
|
||||
}
|
||||
}
|
||||
if (this.replyDestination == null) {
|
||||
|
||||
@@ -45,7 +45,7 @@ public abstract class JmsDestinationAccessorSpec<S extends JmsDestinationAccesso
|
||||
}
|
||||
|
||||
@Override
|
||||
public S id(String id) {
|
||||
public S id(String id) { // NOSONAR - not useless, increases visibility
|
||||
return super.id(id);
|
||||
}
|
||||
|
||||
|
||||
@@ -611,7 +611,7 @@ public class JpaExecutor implements InitializingBean, BeanFactoryAware {
|
||||
catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Value " + evaluationResult + " passed as cannot be " +
|
||||
"parsed to a number, expected to be numeric");
|
||||
"parsed to a number, expected to be numeric", e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BeanPropertyParameterSource implements ParameterSource {
|
||||
return this.beanWrapper.getPropertyValue(paramName);
|
||||
}
|
||||
catch (NotReadablePropertyException ex) {
|
||||
throw new IllegalArgumentException(ex.getMessage());
|
||||
throw new IllegalArgumentException(ex.getMessage()); // NOSONAR - lost stack trace
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,13 +73,13 @@ final class ExpressionEvaluatingParameterSourceUtils {
|
||||
public static class ParameterExpressionEvaluator extends AbstractExpressionEvaluator {
|
||||
|
||||
@Override
|
||||
public StandardEvaluationContext getEvaluationContext() {
|
||||
public StandardEvaluationContext getEvaluationContext() { // NOSONAR - not useless, increases visibility
|
||||
return super.getEvaluationContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public Object evaluateExpression(Expression expression, Object input) {
|
||||
public Object evaluateExpression(Expression expression, Object input) { // NOSONAR - not useless, increases vis.
|
||||
return super.evaluateExpression(expression, input);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,14 +208,19 @@ public class SftpSession implements Session<LsEntry> {
|
||||
}
|
||||
}
|
||||
catch (IOException ioex) {
|
||||
throw new NestedIOException("Failed to delete file " + pathTo, ioex);
|
||||
NestedIOException exception = new NestedIOException("Failed to delete file " + pathTo, sftpex);
|
||||
exception.addSuppressed(ioex);
|
||||
throw exception; // NOSONAR - added to suppressed exceptions
|
||||
}
|
||||
try {
|
||||
// attempt to rename again
|
||||
this.channel.rename(pathFrom, pathTo);
|
||||
}
|
||||
catch (SftpException sftpex2) {
|
||||
throw new NestedIOException("failed to rename from " + pathFrom + " to " + pathTo, sftpex2);
|
||||
NestedIOException exception =
|
||||
new NestedIOException("failed to rename from " + pathFrom + " to " + pathTo, sftpex);
|
||||
exception.addSuppressed(sftpex2);
|
||||
throw exception; // NOSONAR - added to suppressed exceptions
|
||||
}
|
||||
}
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
|
||||
@@ -46,14 +46,14 @@ import org.springframework.util.Base64Utils;
|
||||
* @since 5.0
|
||||
*
|
||||
*/
|
||||
public class TestMailServer {
|
||||
public final class TestMailServer {
|
||||
|
||||
public static SmtpServer smtp(int port) {
|
||||
try {
|
||||
return new SmtpServer(port);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class TestMailServer {
|
||||
return new Pop3Server(port);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class TestMailServer {
|
||||
return new ImapServer(port);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ import org.springframework.messaging.MessageHeaders;
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class HeaderMatcher<T> extends TypeSafeMatcher<Message<T>> {
|
||||
public final class HeaderMatcher<T> extends TypeSafeMatcher<Message<T>> {
|
||||
|
||||
private final Matcher<?> matcher;
|
||||
|
||||
|
||||
@@ -61,9 +61,10 @@ import org.hamcrest.core.AllOf;
|
||||
* @author Iwein Fuld
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class MapContentMatchers<T, V> extends TypeSafeMatcher<Map<? super T, ? super V>> {
|
||||
public final class MapContentMatchers<T, V> extends TypeSafeMatcher<Map<? super T, ? super V>> {
|
||||
|
||||
private final T key;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ import org.springframework.messaging.Message;
|
||||
* @author Artem Bilan
|
||||
*
|
||||
*/
|
||||
public class MockitoMessageMatchers {
|
||||
public final class MockitoMessageMatchers {
|
||||
|
||||
private MockitoMessageMatchers() {
|
||||
super();
|
||||
|
||||
@@ -49,7 +49,7 @@ import org.springframework.messaging.MessageHeaders;
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
|
||||
public final class PayloadAndHeaderMatcher<T> extends BaseMatcher<Message<?>> {
|
||||
|
||||
private final T payload;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ import org.springframework.messaging.Message;
|
||||
* @author Gary Russell
|
||||
*
|
||||
*/
|
||||
public class PayloadMatcher<T> extends TypeSafeMatcher<Message<?>> {
|
||||
public final class PayloadMatcher<T> extends TypeSafeMatcher<Message<?>> {
|
||||
|
||||
private final Matcher<T> matcher;
|
||||
|
||||
|
||||
@@ -42,11 +42,12 @@ import org.springframework.util.ObjectUtils;
|
||||
* enabling debug logging for a test case.
|
||||
*
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 5.0.1
|
||||
*
|
||||
*/
|
||||
public class Log4j2LevelAdjuster implements MethodRule {
|
||||
public final class Log4j2LevelAdjuster implements MethodRule {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(Log4j2LevelAdjuster.class);
|
||||
|
||||
|
||||
@@ -97,11 +97,12 @@ public class OnlyOnceTrigger implements Trigger {
|
||||
public void await() {
|
||||
try {
|
||||
if (!this.latch.await(10000, TimeUnit.MILLISECONDS)) {
|
||||
throw new RuntimeException("test latch.await() did not count down");
|
||||
throw new IllegalStateException("test latch.await() did not count down");
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
throw new RuntimeException("test latch.await() interrupted");
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("test latch.await() interrupted", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -257,7 +257,7 @@ public abstract class TestUtils {
|
||||
logger.warn("Error message was not delivered.", errorDeliveryError);
|
||||
}
|
||||
if (errorDeliveryError instanceof Error) {
|
||||
throw ((Error) errorDeliveryError);
|
||||
throw ((Error) errorDeliveryError); // NOSONAR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.xml.DocumentBuilderFactoryUtils;
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class DomResultFactory implements ResultFactory {
|
||||
|
||||
@@ -46,13 +47,14 @@ public class DomResultFactory implements ResultFactory {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized Result createResult(Object payload) {
|
||||
try {
|
||||
return new DOMResult(getNewDocumentBuilder().newDocument());
|
||||
}
|
||||
catch (ParserConfigurationException e) {
|
||||
throw new MessagingException("failed to create Result for payload type [" +
|
||||
payload.getClass().getName() + "]");
|
||||
payload.getClass().getName() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -246,7 +246,7 @@ public class ZookeeperLockRegistry implements ExpirableLockRegistry, DisposableB
|
||||
this.mutex.acquire();
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException("Failed to acquire mutex at " + this.path, e);
|
||||
throw new IllegalStateException("Failed to acquire mutex at " + this.path, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user