checkstyle Misc Rules

checkstyle Nesting

checkstyle GenericWhitespace

checkstyle MethodParamPad

checkstyle NoWhiteSpace

checkstyle ParenPad Script

checkstyle ParenPad
This commit is contained in:
Gary Russell
2016-04-05 14:58:29 -04:00
committed by Artem Bilan
parent 05cc7be644
commit 57f96bb759
87 changed files with 737 additions and 628 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -33,7 +33,7 @@ import java.lang.annotation.Target;
* @author Dave Syer
* @since 2.0
*/
@Target( { ElementType.PARAMETER, ElementType.METHOD })
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Payloads {

View File

@@ -35,7 +35,7 @@ public abstract class AbstractMessageSourceAdvice implements MethodInterceptor {
public final Object invoke(MethodInvocation invocation) throws Throwable {
Object target = invocation.getThis();
if (!(target instanceof MessageSource)
|| invocation.getMethod().getName() != "receive") {
|| !invocation.getMethod().getName().equals("receive")) {
return invocation.proceed();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -36,12 +36,13 @@ import org.springframework.integration.config.IntegrationRegistrar;
*/
public class AnnotationConfigParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(final Element element, ParserContext parserContext) {
new IntegrationRegistrar().registerBeanDefinitions(new StandardAnnotationMetadata(Object.class) {
@Override
public Map<String, Object> getAnnotationAttributes(String annotationType) {
return Collections.<String, Object> singletonMap("value", element.getAttribute("default-publisher-channel"));
return Collections.<String, Object>singletonMap("value", element.getAttribute("default-publisher-channel"));
}
}, parserContext.getRegistry());

View File

@@ -119,7 +119,7 @@ public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAwar
Assert.notNull(componentNamePatternsSet, "'componentNamePatternsSet' must not be null");
Assert.state(!this.running, "'componentNamePatternsSet' cannot be changed without invoking stop() first");
for (String s : componentNamePatternsSet) {
String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, "," , " ");
String[] componentNamePatterns = StringUtils.delimitedListToStringArray(s, ",", " ");
Arrays.sort(componentNamePatterns);
if (this.componentNamePatternsExplicitlySet
&& !Arrays.equals(this.componentNamePatterns, componentNamePatterns)) {

View File

@@ -159,7 +159,7 @@ public abstract class AbstractMessageGroupStore extends AbstractBatchingMessageG
public int getMessageGroupCount() {
int count = 0;
for (@SuppressWarnings("unused") MessageGroup group : this) {
count ++;
count++;
}
return count;
}

View File

@@ -53,7 +53,7 @@ public class SimpleMessageGroup implements MessageGroup {
private volatile boolean complete;
public SimpleMessageGroup(Object groupId) {
this(Collections.<Message<?>> emptyList(), groupId);
this(Collections.<Message<?>>emptyList(), groupId);
}
public SimpleMessageGroup(Collection<? extends Message<?>> messages, Object groupId) {
@@ -90,6 +90,7 @@ public class SimpleMessageGroup implements MessageGroup {
return this.timestamp;
}
@Override
public void setLastModified(long lastModified) {
this.lastModified = lastModified;
}
@@ -104,10 +105,12 @@ public class SimpleMessageGroup implements MessageGroup {
return true;
}
@Override
public void add(Message<?> messageToAdd) {
addMessage(messageToAdd);
}
@Override
public boolean remove(Message<?> message) {
return this.messages.remove(message);
}
@@ -126,6 +129,7 @@ public class SimpleMessageGroup implements MessageGroup {
return Collections.unmodifiableCollection(this.messages);
}
@Override
public void setLastReleasedMessageSequenceNumber(int sequenceNumber) {
this.lastReleasedMessageSequence = sequenceNumber;
}
@@ -166,6 +170,7 @@ public class SimpleMessageGroup implements MessageGroup {
}
}
@Override
public void clear() {
this.messages.clear();
}

View File

@@ -45,7 +45,7 @@ public class SimpleMessageGroupFactory implements MessageGroupFactory {
@Override
public MessageGroup create(Object groupId) {
return create(Collections.<Message<?>> emptyList(), groupId);
return create(Collections.<Message<?>>emptyList(), groupId);
}
@Override

View File

@@ -37,12 +37,12 @@ public class IdGenerators {
*/
public static class JdkIdGenerator implements IdGenerator {
@Override
public UUID generateId() {
return UUID.randomUUID();
}
@Override
public UUID generateId() {
return UUID.randomUUID();
}
}
}
/**
* Based on the two {@link AtomicLong}s, for {@code topBits} and {@code bottomBits},
@@ -59,23 +59,23 @@ public class IdGenerators {
* is initialized. Therefore, it is not suitable when persisting messages based on their ID; it should
* only be used when the absolute best performance is required and messages are not persisted.
*/
public static class SimpleIncrementingIdGenerator implements IdGenerator {
public static class SimpleIncrementingIdGenerator implements IdGenerator {
private final AtomicLong topBits = new AtomicLong();
private final AtomicLong topBits = new AtomicLong();
private final AtomicLong bottomBits = new AtomicLong();
private final AtomicLong bottomBits = new AtomicLong();
@Override
public UUID generateId() {
long bottomBits = this.bottomBits.incrementAndGet();
if (bottomBits == 0) {
return new UUID(this.topBits.incrementAndGet(), bottomBits);
}
else {
return new UUID(this.topBits.get(), bottomBits);
}
}
@Override
public UUID generateId() {
long bottomBits = this.bottomBits.incrementAndGet();
if (bottomBits == 0) {
return new UUID(this.topBits.incrementAndGet(), bottomBits);
}
else {
return new UUID(this.topBits.get(), bottomBits);
}
}
}
}
}

View File

@@ -42,7 +42,7 @@ public abstract class AbstractJacksonJsonObjectMapper<N, P, J> extends JsonObjec
implements BeanClassLoaderAware {
protected static final Collection<Class<?>> supportedJsonTypes =
Arrays.<Class<?>> asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class);
Arrays.<Class<?>>asList(String.class, byte[].class, File.class, URL.class, InputStream.class, Reader.class);
private volatile ClassLoader classLoader = ClassUtils.getDefaultClassLoader();

View File

@@ -60,7 +60,7 @@ public final class DefaultLockRegistry implements LockRegistry {
*/
public DefaultLockRegistry(int mask) {
String bits = Integer.toBinaryString(mask);
Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1') ), "Mask must be a power of 2 - 1");
Assert.isTrue(bits.length() < 32 && (mask == 0 || bits.lastIndexOf('0') < bits.indexOf('1')), "Mask must be a power of 2 - 1");
this.mask = mask;
int arraySize = this.mask + 1;
this.lockTable = new ReentrantLock[arraySize];

View File

@@ -115,7 +115,7 @@ public class ObjectToMapTransformer extends AbstractPayloadTransformer<Object, M
int counter = 0;
for (Object element : list) {
this.doProcessElement(propertyPrefix + "[" + counter + "]", element, resultMap);
counter ++;
counter++;
}
}

View File

@@ -831,7 +831,7 @@ public class MessagingMethodInvokerHelper<T> extends AbstractExpressionEvaluator
headerName = methodParameter.getParameterName();
}
else if (valueAttribute.indexOf('.') != -1) {
String tokens[] = valueAttribute.split("\\.", 2);
String[] tokens = valueAttribute.split("\\.", 2);
headerName = tokens[0];
if (StringUtils.hasText(tokens[1])) {
relativeExpression = "." + tokens[1];

View File

@@ -32,7 +32,6 @@ import org.junit.Test;
import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.store.MessageGroup;
import org.springframework.integration.store.MessageGroupStore;
@@ -41,6 +40,7 @@ import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessageHandlingException;
import org.springframework.messaging.MessageHeaders;
/**
@@ -80,7 +80,7 @@ public class ConcurrentAggregatorTests {
assertTrue(latch.await(10, TimeUnit.SECONDS));
assertThat(latch.getCount(), is(0l));
assertThat(latch.getCount(), is(0L));
Message<?> reply = replyChannel.receive(2000);
assertNotNull(reply);
assertEquals(reply.getPayload(), 105);
@@ -319,6 +319,7 @@ public class ConcurrentAggregatorTests {
return this.exception;
}
@Override
public void run() {
try {
this.aggregator.handleMessage(message);
@@ -335,6 +336,7 @@ public class ConcurrentAggregatorTests {
private class MultiplyingProcessor implements MessageGroupProcessor {
@Override
public Object processMessageGroup(MessageGroup group) {
Integer product = 1;
for (Message<?> message : group.getMessages()) {
@@ -346,6 +348,7 @@ public class ConcurrentAggregatorTests {
private class NullReturningMessageProcessor implements MessageGroupProcessor {
@Override
public Object processMessageGroup(MessageGroup group) {
return null;
}

View File

@@ -81,11 +81,11 @@ public class ResequencerTests {
Message<?> reply2 = replyChannel.receive(0);
Message<?> reply3 = replyChannel.receive(0);
assertNotNull(reply1);
assertThat( new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1));
assertThat(new IntegrationMessageHeaderAccessor(reply1).getSequenceNumber(), is(1));
assertNotNull(reply2);
assertThat(new IntegrationMessageHeaderAccessor(reply2).getSequenceNumber(), is(2));
assertNotNull(reply3);
assertThat( new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3));
assertThat(new IntegrationMessageHeaderAccessor(reply3).getSequenceNumber(), is(3));
}
@Test

View File

@@ -24,7 +24,7 @@ import java.util.List;
public class Adder {
public Long add(List<Long> results) {
long total = 0l;
long total = 0L;
for (long partialResult: results) {
total += partialResult;
}

View File

@@ -190,7 +190,7 @@ public class AggregatorParserTests {
outputChannel, accessor.getPropertyValue("outputChannel"));
assertEquals("The AggregatorEndpoint is not injected with the appropriate discard channel",
discardChannel, accessor.getPropertyValue("discardChannel"));
assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000l,
assertEquals("The AggregatorEndpoint is not set with the appropriate timeout value", 86420000L,
TestUtils.getPropertyValue(consumer, "messagingTemplate.sendTimeout"));
assertEquals(
"The AggregatorEndpoint is not configured with the appropriate 'send partial results on timeout' flag",
@@ -212,15 +212,15 @@ public class AggregatorParserTests {
public void testSimpleJavaBeanAggregator() {
List<Message<?>> outboundMessages = new ArrayList<Message<?>>();
MessageChannel input = (MessageChannel) context.getBean("aggregatorWithReferenceAndMethodInput");
outboundMessages.add(createMessage(1l, "id1", 3, 1, null));
outboundMessages.add(createMessage(2l, "id1", 3, 3, null));
outboundMessages.add(createMessage(3l, "id1", 3, 2, null));
outboundMessages.add(createMessage(1L, "id1", 3, 1, null));
outboundMessages.add(createMessage(2L, "id1", 3, 3, null));
outboundMessages.add(createMessage(3L, "id1", 3, 2, null));
for (Message<?> message : outboundMessages) {
input.send(message);
}
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
Message<?> response = outputChannel.receive(10);
Assert.assertEquals(6l, response.getPayload());
Assert.assertEquals(6L, response.getPayload());
Object mbf = context.getBean(IntegrationUtils.INTEGRATION_MESSAGE_BUILDER_FACTORY_BEAN_NAME);
Object handler = context.getBean("aggregatorWithReferenceAndMethod.handler");
assertSame(mbf, TestUtils.getPropertyValue(handler, "outputProcessor.messageBuilderFactory"));
@@ -261,16 +261,16 @@ public class AggregatorParserTests {
assertNull(handlerMethods);
Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod");
assertTrue(handlerMethod.toString().contains("checkCompleteness"));
input.send(createMessage(1l, "correllationId", 4, 0, null));
input.send(createMessage(2l, "correllationId", 4, 1, null));
input.send(createMessage(3l, "correllationId", 4, 2, null));
input.send(createMessage(1L, "correllationId", 4, 0, null));
input.send(createMessage(2L, "correllationId", 4, 1, null));
input.send(createMessage(3L, "correllationId", 4, 2, null));
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
Message<?> reply = outputChannel.receive(0);
Assert.assertNull(reply);
input.send(createMessage(5l, "correllationId", 4, 3, null));
input.send(createMessage(5L, "correllationId", 4, 3, null));
reply = outputChannel.receive(0);
Assert.assertNotNull(reply);
assertEquals(11l, reply.getPayload());
assertEquals(11L, reply.getPayload());
}
@Test // see INT-2011
@@ -286,16 +286,16 @@ public class AggregatorParserTests {
assertNull(handlerMethods);
Object handlerMethod = releaseStrategyAccessor.getPropertyValue("handlerMethod");
assertTrue(handlerMethod.toString().contains("checkCompleteness"));
input.send(createMessage(1l, "correllationId", 4, 0, null));
input.send(createMessage(2l, "correllationId", 4, 1, null));
input.send(createMessage(3l, "correllationId", 4, 2, null));
input.send(createMessage(1L, "correllationId", 4, 0, null));
input.send(createMessage(2L, "correllationId", 4, 1, null));
input.send(createMessage(3L, "correllationId", 4, 2, null));
PollableChannel outputChannel = (PollableChannel) context.getBean("outputChannel");
Message<?> reply = outputChannel.receive(0);
Assert.assertNull(reply);
input.send(createMessage(5l, "correllationId", 4, 3, null));
input.send(createMessage(5L, "correllationId", 4, 3, null));
reply = outputChannel.receive(0);
Assert.assertNotNull(reply);
assertEquals(11l, reply.getPayload());
assertEquals(11L, reply.getPayload());
}
@Test

View File

@@ -88,7 +88,7 @@ public class ResequencerParserTests {
getPropertyValue(resequencer, "outputChannel"));
assertEquals("The ResequencerEndpoint is not injected with the appropriate discard channel", discardChannel,
getPropertyValue(resequencer, "discardChannel"));
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000l,
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value", 86420000L,
getPropertyValue(resequencer, "messagingTemplate.sendTimeout"));
assertEquals(
"The ResequencerEndpoint is not configured with the appropriate 'send partial results on timeout' flag",

View File

@@ -68,7 +68,7 @@ public class AggregatorAnnotationTests {
assertTrue(getPropertyValue(aggregator, "releaseStrategy") instanceof SequenceSizeReleaseStrategy);
assertEquals("outputChannel", getPropertyValue(aggregator, "outputChannelName"));
assertEquals("discardChannel", getPropertyValue(aggregator, "discardChannelName"));
assertEquals(98765432l, getPropertyValue(aggregator, "messagingTemplate.sendTimeout"));
assertEquals(98765432L, getPropertyValue(aggregator, "messagingTemplate.sendTimeout"));
assertEquals(true, getPropertyValue(aggregator, "sendPartialResultOnExpiry"));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 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.
@@ -90,7 +90,7 @@ public class DefaultConfiguringBeanFactoryPostProcessorTests {
assertNotNull("Child task scheduler was null", childScheduler);
assertNotNull("Parent task scheduler was null", parentScheduler);
assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler );
assertEquals("Different schedulers in parent and child", parentScheduler, childScheduler);
}
}

View File

@@ -20,6 +20,7 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.DirectFieldAccessor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -50,7 +51,7 @@ public class IntervalTriggerParserTests {
Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate");
Long period = (Long) accessor.getPropertyValue("period");
assertEquals(fixedRate, true);
assertEquals(36l, period.longValue());
assertEquals(36L, period.longValue());
}
@Test
@@ -64,6 +65,6 @@ public class IntervalTriggerParserTests {
Boolean fixedRate = (Boolean) accessor.getPropertyValue("fixedRate");
Long period = (Long) accessor.getPropertyValue("period");
assertEquals(fixedRate, false);
assertEquals(37l, period.longValue());
assertEquals(37L, period.longValue());
}
}

View File

@@ -30,12 +30,12 @@ import org.springframework.beans.factory.BeanFactory;
import org.springframework.expression.Expression;
import org.springframework.expression.common.LiteralExpression;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.integration.mapping.MessageMappingException;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Headers;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.integration.mapping.MessageMappingException;
import org.springframework.integration.support.MessageBuilder;
/**
* @author Mark Fisher
@@ -57,7 +57,7 @@ public class GatewayMethodInboundMessageMapperToMessageTests {
Method method = TestService.class.getMethod("sendPayload", String.class);
GatewayMethodInboundMessageMapper mapper = new GatewayMethodInboundMessageMapper(method);
mapper.setBeanFactory(mock(BeanFactory.class));
mapper.toMessage(new Object[] { "test" , "oops" });
mapper.toMessage(new Object[] { "test", "oops" });
}
@Test(expected = IllegalArgumentException.class)

View File

@@ -339,7 +339,7 @@ public class GatewayProxyFactoryBeanTests {
gpfb.setDefaultRequestChannel(drc);
gpfb.setDefaultReplyTimeout(0L);
GatewayMethodMetadata meta = new GatewayMethodMetadata();
meta.setHeaderExpressions(Collections. <String, Expression> singletonMap("foo", new LiteralExpression("bar")));
meta.setHeaderExpressions(Collections.<String, Expression>singletonMap("foo", new LiteralExpression("bar")));
gpfb.setGlobalMethodMetadata(meta);
gpfb.afterPropertiesSet();
((TestEchoService) gpfb.getObject()).echo("foo");

View File

@@ -63,7 +63,7 @@ public class BridgeHandlerTests {
@Test(timeout = 1000)
public void missingOutputChannelAllowedForReplyChannelMessages() throws Exception {
PollableChannel replyChannel = new QueueChannel();
Message<String> request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel ).build();
Message<String> request = MessageBuilder.withPayload("tst").setReplyChannel(replyChannel).build();
handler.handleMessage(request);
assertThat(replyChannel.receive(), sameExceptImmutableHeaders(request));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2011 the original author or authors.
* Copyright 2002-2016 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.
@@ -66,7 +66,7 @@ public class MultiChannelRouterTests {
AbstractMappingMessageRouter router = new AbstractMappingMessageRouter() {
@SuppressWarnings("unchecked")
public List<Object> getChannelKeys(Message<?> message) {
return CollectionUtils.arrayToList(new String[] {"noSuchChannel"} );
return CollectionUtils.arrayToList(new String[] {"noSuchChannel"});
}
};
TestChannelResolver channelResolver = new TestChannelResolver();

View File

@@ -45,7 +45,7 @@ public class SimpleMessageGroupTests {
private final Object key = new Object();
private SimpleMessageGroup group = new SimpleMessageGroup(Collections.<Message<?>> emptyList(), key);
private SimpleMessageGroup group = new SimpleMessageGroup(Collections.<Message<?>>emptyList(), key);
@SuppressWarnings("unchecked")
public void prepareForSequenceAwareMessageGroup() throws Exception {

View File

@@ -40,7 +40,7 @@ public class SmartLifecycleRoleControllerTests {
when(lc1.getPhase()).thenReturn(2);
SmartLifecycle lc2 = mock(SmartLifecycle.class);
when(lc1.getPhase()).thenReturn(1);
MultiValueMap<String , SmartLifecycle> map = new LinkedMultiValueMap<String, SmartLifecycle>();
MultiValueMap<String, SmartLifecycle> map = new LinkedMultiValueMap<String, SmartLifecycle>();
map.add("foo", lc1);
map.add("foo", lc2);
SmartLifecycleRoleController controller = new SmartLifecycleRoleController(map);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2016 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.
@@ -523,7 +523,9 @@ public class ContentEnricherTests {
@SuppressWarnings("unused")
private static final class Source {
private final String firstName, lastName;
private final String firstName;
private final String lastName;
Source(String firstName, String lastName) {
this.firstName = firstName;

View File

@@ -37,7 +37,7 @@ public class PayloadTypeConvertingTransformerTests {
@Test
public void testTransformPayloadObject() throws Exception {
PayloadTypeConvertingTransformer<String, String> tx = new PayloadTypeConvertingTransformer<String, String>();
tx.setConverter(new Converter<String, String> () {
tx.setConverter(new Converter<String, String>() {
@Override
public String convert(String source) {