Fix Sonar smells in the FtpSession

This commit is contained in:
Artem Bilan
2019-08-29 10:19:45 -04:00
parent ca8377da9b
commit 1b892fc7a4

View File

@@ -151,12 +151,8 @@ public class FtpSession implements Session<FTPFile> {
@Override @Override
public void close() { public void close() {
try { try {
if (this.readingRaw.get()) { if (this.readingRaw.get() && !finalizeRaw() && LOGGER.isWarnEnabled()) {
if (!finalizeRaw()) { LOGGER.warn("Finalize on readRaw() returned false for " + this);
if (LOGGER.isWarnEnabled()) {
LOGGER.warn("Finalize on readRaw() returned false for " + this);
}
}
} }
this.client.disconnect(); this.client.disconnect();
} }
@@ -181,11 +177,11 @@ public class FtpSession implements Session<FTPFile> {
this.client.deleteFile(pathTo); this.client.deleteFile(pathTo);
boolean completed = this.client.rename(pathFrom, pathTo); boolean completed = this.client.rename(pathFrom, pathTo);
if (!completed) { if (!completed) {
throw new IOException("Failed to rename '" + pathFrom + throw new IOException("Failed to rename " + pathFrom +
"' to " + pathTo + SERVER_REPLIED_WITH + this.client.getReplyString()); " to " + pathTo + SERVER_REPLIED_WITH + this.client.getReplyString());
} }
if (LOGGER.isInfoEnabled()) { if (LOGGER.isInfoEnabled()) {
LOGGER.info("File has been successfully renamed from: " + pathFrom + " to " + pathTo); LOGGER.info("File has been successfully renamed from " + pathFrom + " to " + pathTo);
} }
} }