Sonar fixes

Hidden fields, `o.s.i.a*` through `o.s.i.j*`.
This commit is contained in:
Gary Russell
2019-01-08 15:03:00 -05:00
committed by Artem Bilan
parent 6eeec50b4a
commit e40cfe101e
53 changed files with 486 additions and 467 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -396,39 +396,39 @@ public class FileWritingMessageHandler extends AbstractReplyProducingMessageHand
* representing the bits that were set in the chmod value.
*/
BitSet bits = BitSet.valueOf(new byte[] { (byte) chmod, (byte) (chmod >> 8) });
final Set<PosixFilePermission> permissions = new HashSet<>();
final Set<PosixFilePermission> posixPermissions = new HashSet<>();
bits.stream().forEach(b -> {
switch (b) {
case 0:
permissions.add(PosixFilePermission.OTHERS_EXECUTE);
posixPermissions.add(PosixFilePermission.OTHERS_EXECUTE);
break;
case 1:
permissions.add(PosixFilePermission.OTHERS_WRITE);
posixPermissions.add(PosixFilePermission.OTHERS_WRITE);
break;
case 2:
permissions.add(PosixFilePermission.OTHERS_READ);
posixPermissions.add(PosixFilePermission.OTHERS_READ);
break;
case 3:
permissions.add(PosixFilePermission.GROUP_EXECUTE);
posixPermissions.add(PosixFilePermission.GROUP_EXECUTE);
break;
case 4:
permissions.add(PosixFilePermission.GROUP_WRITE);
posixPermissions.add(PosixFilePermission.GROUP_WRITE);
break;
case 5:
permissions.add(PosixFilePermission.GROUP_READ);
posixPermissions.add(PosixFilePermission.GROUP_READ);
break;
case 6:
permissions.add(PosixFilePermission.OWNER_EXECUTE);
posixPermissions.add(PosixFilePermission.OWNER_EXECUTE);
break;
case 7:
permissions.add(PosixFilePermission.OWNER_WRITE);
posixPermissions.add(PosixFilePermission.OWNER_WRITE);
break;
case 8:
permissions.add(PosixFilePermission.OWNER_READ);
posixPermissions.add(PosixFilePermission.OWNER_READ);
break;
}
});
this.permissions = permissions;
this.permissions = posixPermissions;
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@@ -38,9 +38,8 @@ public class HeadDirectoryScanner extends DefaultDirectoryScanner {
private final HeadFilter headFilter;
public HeadDirectoryScanner(int maxNumberOfFiles) {
HeadFilter headFilter = new HeadFilter(maxNumberOfFiles);
this.headFilter = headFilter;
this.setFilter(headFilter);
this.headFilter = new HeadFilter(maxNumberOfFiles);
setFilter(this.headFilter);
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -63,7 +63,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
private volatile Boolean reopen;
private volatile FileTailingMessageProducerSupport adapter;
private volatile FileTailingMessageProducerSupport tailAdapter;
private volatile String beanName;
@@ -158,40 +158,40 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
@Override
public void start() {
if (this.adapter != null) {
this.adapter.start();
if (this.tailAdapter != null) {
this.tailAdapter.start();
}
}
@Override
public void stop() {
if (this.adapter != null) {
this.adapter.stop();
if (this.tailAdapter != null) {
this.tailAdapter.stop();
}
}
@Override
public boolean isRunning() {
return this.adapter != null && this.adapter.isRunning();
return this.tailAdapter != null && this.tailAdapter.isRunning();
}
@Override
public int getPhase() {
if (this.adapter != null) {
return this.adapter.getPhase();
if (this.tailAdapter != null) {
return this.tailAdapter.getPhase();
}
return 0;
}
@Override
public boolean isAutoStartup() {
return this.adapter != null && this.adapter.isAutoStartup();
return this.tailAdapter != null && this.tailAdapter.isAutoStartup();
}
@Override
public void stop(Runnable callback) {
if (this.adapter != null) {
this.adapter.stop(callback);
if (this.tailAdapter != null) {
this.tailAdapter.stop(callback);
}
else {
callback.run();
@@ -200,7 +200,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
@Override
public Class<?> getObjectType() {
return this.adapter == null ? FileTailingMessageProducerSupport.class : this.adapter.getClass();
return this.tailAdapter == null ? FileTailingMessageProducerSupport.class : this.tailAdapter.getClass();
}
@Override
@@ -256,7 +256,7 @@ public class FileTailInboundChannelAdapterFactoryBean extends AbstractFactoryBea
adapter.setBeanFactory(getBeanFactory()); // NOSONAR never null
}
adapter.afterPropertiesSet();
this.adapter = adapter;
this.tailAdapter = adapter;
return adapter;
}

View File

@@ -239,19 +239,18 @@ public class RemoteFileTemplate<F> implements RemoteFileOperations<F>, Initializ
@Override
public void afterPropertiesSet() {
BeanFactory beanFactory = this.beanFactory;
if (beanFactory != null) {
if (this.beanFactory != null) {
if (this.directoryExpressionProcessor != null) {
this.directoryExpressionProcessor.setBeanFactory(beanFactory);
this.directoryExpressionProcessor.setBeanFactory(this.beanFactory);
}
if (this.temporaryDirectoryExpressionProcessor != null) {
this.temporaryDirectoryExpressionProcessor.setBeanFactory(beanFactory);
this.temporaryDirectoryExpressionProcessor.setBeanFactory(this.beanFactory);
}
if (!this.fileNameGeneratorSet && this.fileNameGenerator instanceof BeanFactoryAware) {
((BeanFactoryAware) this.fileNameGenerator).setBeanFactory(beanFactory);
((BeanFactoryAware) this.fileNameGenerator).setBeanFactory(this.beanFactory);
}
if (this.fileNameProcessor != null) {
this.fileNameProcessor.setBeanFactory(beanFactory);
this.fileNameProcessor.setBeanFactory(this.beanFactory);
}
}
if (this.autoCreateDirectory) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -891,11 +891,11 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
}
File localFile =
new File(generateLocalDirectory(message, remoteDir), generateLocalFileName(message, remoteFilename));
FileExistsMode fileExistsMode = this.fileExistsMode;
boolean appending = FileExistsMode.APPEND.equals(fileExistsMode);
FileExistsMode existsMode = this.fileExistsMode;
boolean appending = FileExistsMode.APPEND.equals(existsMode);
boolean exists = localFile.exists();
boolean replacing = FileExistsMode.REPLACE.equals(fileExistsMode)
|| (exists && FileExistsMode.REPLACE_IF_MODIFIED.equals(fileExistsMode)
boolean replacing = FileExistsMode.REPLACE.equals(existsMode)
|| (exists && FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)
&& localFile.lastModified() != getModified(fileInfo));
if (!exists || appending || replacing) {
OutputStream outputStream;
@@ -939,7 +939,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
throw new MessagingException("Failed to rename local file");
}
if (this.options.contains(Option.PRESERVE_TIMESTAMP)
|| FileExistsMode.REPLACE_IF_MODIFIED.equals(fileExistsMode)) {
|| FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)) {
localFile.setLastModified(getModified(fileInfo));
}
if (this.options.contains(Option.DELETE)) {
@@ -952,7 +952,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
}
}
}
else if (FileExistsMode.REPLACE_IF_MODIFIED.equals(fileExistsMode)) {
else if (FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)) {
if (logger.isDebugEnabled()) {
logger.debug("Local file '" + localFile + "' has the same modified timestamp, ignored");
}
@@ -960,7 +960,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
localFile = null;
}
}
else if (!FileExistsMode.IGNORE.equals(fileExistsMode)) {
else if (!FileExistsMode.IGNORE.equals(existsMode)) {
throw new MessageHandlingException(message, "Local file " + localFile + " already exists");
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -153,7 +153,7 @@ public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBe
if (this.isSharedSessionCapable && ((SharedSessionCapable) this.sessionFactory).isSharedSession()) {
((SharedSessionCapable) this.sessionFactory).resetSharedSession();
}
long sharedSessionEpoch = System.nanoTime();
long epoch = System.nanoTime();
/*
* Spin until we get a new value - nano precision but may be lower resolution.
* We reset the epoch AFTER resetting the shared session so there is no possibility
@@ -161,10 +161,10 @@ public class CachingSessionFactory<F> implements SessionFactory<F>, DisposableBe
* that a "new" session might appear in the old epoch and thus be closed when returned to
* the cache.
*/
while (sharedSessionEpoch == this.sharedSessionEpoch) {
sharedSessionEpoch = System.nanoTime();
while (epoch == this.sharedSessionEpoch) {
epoch = System.nanoTime();
}
this.sharedSessionEpoch = sharedSessionEpoch;
this.sharedSessionEpoch = epoch;
this.pool.removeAllIdleItems();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2018 the original author or authors.
* Copyright 2015-2019 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.
@@ -78,7 +78,7 @@ public class FileSplitter extends AbstractMessageSplitter {
private static final JsonObjectMapper<?, ?> objectMapper =
JsonObjectMapperProvider.jsonAvailable() ? JsonObjectMapperProvider.newInstance() : null;
private final boolean iterator;
private final boolean returnIterator;
private final boolean markers;
@@ -135,7 +135,7 @@ public class FileSplitter extends AbstractMessageSplitter {
* @since 4.2.7
*/
public FileSplitter(boolean iterator, boolean markers, boolean markersJson) {
this.iterator = iterator;
this.returnIterator = iterator;
this.markers = markers;
if (markers) {
setApplySequence(false);
@@ -359,7 +359,7 @@ public class FileSplitter extends AbstractMessageSplitter {
};
if (this.iterator) {
if (this.returnIterator) {
return iterator;
}
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@@ -71,9 +71,9 @@ public class ApacheCommonsFileTailingMessageProducer extends FileTailingMessageP
@Override
protected void doStart() {
super.doStart();
Tailer tailer = new Tailer(this.getFile(), this, this.pollingDelay, this.end, this.reopen);
this.getTaskExecutor().execute(tailer);
this.tailer = tailer;
Tailer theTailer = new Tailer(this.getFile(), this, this.pollingDelay, this.end, this.reopen);
this.getTaskExecutor().execute(theTailer);
this.tailer = theTailer;
}
@Override

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2019 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.
@@ -149,11 +149,11 @@ public abstract class FileTailingMessageProducerSupport extends MessageProducerS
this.idleEventScheduledFuture = getTaskScheduler().scheduleWithFixedDelay(() -> {
long now = System.currentTimeMillis();
long lastAlertAt = this.lastNoMessageAlert.get();
long lastProduce = this.lastProduce;
if (now > lastProduce + this.idleEventInterval
long lastSend = this.lastProduce;
if (now > lastSend + this.idleEventInterval
&& now > lastAlertAt + this.idleEventInterval
&& this.lastNoMessageAlert.compareAndSet(lastAlertAt, now)) {
publishIdleEvent(now - lastProduce);
publishIdleEvent(now - lastSend);
}
}, this.idleEventInterval);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@@ -39,7 +39,7 @@ import org.springframework.util.Assert;
public class OSDelegatingFileTailingMessageProducer extends FileTailingMessageProducerSupport
implements SchedulingAwareRunnable {
private volatile Process process;
private volatile Process nativeTailProcess;
private volatile String options = "-F -n 0";
@@ -47,7 +47,7 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
private volatile boolean enableStatusReader = true;
private volatile BufferedReader reader;
private volatile BufferedReader stdOutReader;
public void setOptions(String options) {
if (options == null) {
@@ -103,10 +103,10 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
}
private void destroyProcess() {
Process process = this.process;
Process process = this.nativeTailProcess;
if (process != null) {
process.destroy();
this.process = null;
this.nativeTailProcess = null;
}
}
@@ -121,12 +121,12 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
try {
Process process = Runtime.getRuntime().exec(this.command);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
this.process = process;
this.nativeTailProcess = process;
this.startProcessMonitor();
if (this.enableStatusReader) {
startStatusReader();
}
this.reader = reader;
this.stdOutReader = reader;
this.getTaskExecutor().execute(this);
}
catch (IOException e) {
@@ -140,7 +140,7 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
*/
private void startProcessMonitor() {
this.getTaskExecutor().execute(() -> {
Process process = OSDelegatingFileTailingMessageProducer.this.process;
Process process = OSDelegatingFileTailingMessageProducer.this.nativeTailProcess;
if (process == null) {
if (logger.isDebugEnabled()) {
logger.debug("Process destroyed before starting process monitor");
@@ -181,7 +181,7 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
* (file not available, rotations etc) are sent to stderr.
*/
private void startStatusReader() {
Process process = this.process;
Process process = this.nativeTailProcess;
if (process == null) {
if (logger.isDebugEnabled()) {
logger.debug("Process destroyed before starting stderr reader");
@@ -230,7 +230,7 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
if (logger.isDebugEnabled()) {
logger.debug("Reading stdout");
}
while ((line = this.reader.readLine()) != null) {
while ((line = this.stdOutReader.readLine()) != null) {
this.send(line);
}
}
@@ -239,7 +239,7 @@ public class OSDelegatingFileTailingMessageProducer extends FileTailingMessagePr
logger.debug("Exception on tail reader", e);
}
try {
this.reader.close();
this.stdOutReader.close();
}
catch (IOException e1) {
if (logger.isDebugEnabled()) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2015-2017 the original author or authors.
* Copyright 2015-2019 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.
@@ -60,7 +60,7 @@ public class FileSplitterParserTests {
@Test
public void testComplete() {
assertFalse(TestUtils.getPropertyValue(this.splitter, "iterator", Boolean.class));
assertFalse(TestUtils.getPropertyValue(this.splitter, "returnIterator", Boolean.class));
assertTrue(TestUtils.getPropertyValue(this.splitter, "markers", Boolean.class));
assertTrue(TestUtils.getPropertyValue(this.splitter, "markersJson", Boolean.class));
assertTrue(TestUtils.getPropertyValue(this.splitter, "requiresReply", Boolean.class));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2019 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.
@@ -95,7 +95,7 @@ public class FileTailingMessageProducerTests {
public void testOS() throws Exception {
OSDelegatingFileTailingMessageProducer adapter = new OSDelegatingFileTailingMessageProducer();
adapter.setOptions(TAIL_OPTIONS_FOLLOW_NAME_ALL_LINES);
testGuts(adapter, "reader");
testGuts(adapter, "stdOutReader");
}
@Test