INT-3626: More Sonar Fixes

JIRA: https://jira.spring.io/browse/INT-3626

Remove Direct Array Usages.

With the increased use of java configuration and DSL, it
is no longer safe to directly use array arguments.

(Except in simple wrapper objects).

Avoid (or mark //NOSONAR) catch Throwable.

Remove unused field.
This commit is contained in:
Gary Russell
2015-02-11 10:34:29 -05:00
parent bc509da062
commit 632740d2cf
27 changed files with 225 additions and 102 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2015 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.
@@ -15,6 +15,8 @@
*/
package org.springframework.integration.ip.tcp.connection;
import java.util.Arrays;
/**
* @author Gary Russell
* @since 2.0
@@ -25,11 +27,11 @@ public class TcpConnectionInterceptorFactoryChain {
private TcpConnectionInterceptorFactory[] interceptorFactories;
public TcpConnectionInterceptorFactory[] getInterceptorFactories() {
return interceptorFactories;
return interceptorFactories;//NOSONAR
}
public void setInterceptors(TcpConnectionInterceptorFactory[] interceptorFactories) {
this.interceptorFactories = interceptorFactories;
this.interceptorFactories = Arrays.copyOf(interceptorFactories, interceptorFactories.length);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 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.
@@ -159,7 +159,7 @@ public class TcpNioSSLConnection extends TcpNioConnection {
}
switch (result.getHandshakeStatus()) {
case FINISHED:
resumeWriterIfNeeded();
resumeWriterIfNeeded();//NOSONAR - fall-through inteded
// switch fall-through intended
case NOT_HANDSHAKING:
case NEED_UNWRAP:

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014 the original author or authors.
* Copyright 2014-2015 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.
@@ -34,14 +34,15 @@ public class TcpDeserializationExceptionEvent extends IpIntegrationEvent {
private final int offset;
public TcpDeserializationExceptionEvent(Object source, Throwable cause, byte[] buffer, int offset) {
public TcpDeserializationExceptionEvent(Object source, Throwable cause, byte[] buffer,//NOSONAR - direct storage
int offset) {
super(source, cause);
this.buffer = buffer;
this.buffer = buffer;//NOSONAR - direct storage
this.offset = offset;
}
public byte[] getBuffer() {
return buffer;
return buffer;//NOSONAR - direct access
}
public int getOffset() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2001-2013 the original author or authors.
* Copyright 2001-2015 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.
@@ -75,8 +75,6 @@ public class UnicastSendingMessageHandler extends
private volatile Map<String, CountDownLatch> ackControl = Collections
.synchronizedMap(new HashMap<String, CountDownLatch>());
private volatile Exception fatalException;
private volatile int soReceiveBufferSize = -1;
private volatile String localAddress;
@@ -224,9 +222,6 @@ public class UnicastSendingMessageHandler extends
try {
DatagramPacket packet;
if (this.waitForAck) {
if (this.fatalException != null) {
throw new MessagingException(message, "Acknowledgment failure", fatalException);
}
countdownLatch = new CountDownLatch(ackCounter);
this.ackControl.put(messageId, countdownLatch);
}
@@ -402,10 +397,6 @@ public class UnicastSendingMessageHandler extends
* (bind) error occurred, without bouncing the JVM.
*/
public void restartAckThread() {
if (fatalException == null) {
return;
}
this.fatalException = null;
this.taskExecutor.execute(this);
}