Sonar fixes
- printStackTrace in test mail server - Illegal throws - Large anon. classes * - indexOf char - stored external object * - ignored exceptional return values * - checkstyle
This commit is contained in:
committed by
Artem Bilan
parent
4199ff57cd
commit
0bb901b286
@@ -32,6 +32,9 @@ import java.util.concurrent.Executors;
|
||||
|
||||
import javax.net.ServerSocketFactory;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.util.Base64Utils;
|
||||
|
||||
/**
|
||||
@@ -145,7 +148,7 @@ public final class TestMailServer {
|
||||
messages.add(sb.toString());
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error(IO_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +208,7 @@ public final class TestMailServer {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error(IO_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +259,7 @@ public final class TestMailServer {
|
||||
if (line == null) {
|
||||
break;
|
||||
}
|
||||
String tag = line.substring(0, line.indexOf(" ") + 1);
|
||||
String tag = line.substring(0, line.indexOf(' ') + 1);
|
||||
if (line.endsWith("CAPABILITY")) {
|
||||
write("* CAPABILITY IDLE IMAP4rev1");
|
||||
write(tag + "OK CAPABILITY completed");
|
||||
@@ -357,7 +360,7 @@ public final class TestMailServer {
|
||||
write("* 2 EXISTS");
|
||||
seen = false;
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (@SuppressWarnings("unused") InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
@@ -373,7 +376,7 @@ public final class TestMailServer {
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error(IO_EXCEPTION, e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,6 +396,10 @@ public final class TestMailServer {
|
||||
|
||||
public abstract static class MailServer implements Runnable {
|
||||
|
||||
protected final Log LOGGER = LogFactory.getLog(getClass()); // NOSONAR
|
||||
|
||||
protected static final String IO_EXCEPTION = "IOException"; // NOSONAR
|
||||
|
||||
private final ServerSocket serverSocket;
|
||||
|
||||
private final ExecutorService exec = Executors.newCachedThreadPool();
|
||||
@@ -437,7 +444,7 @@ public final class TestMailServer {
|
||||
exec.execute(mailHandler(socket));
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
catch (@SuppressWarnings("unused") IOException e) {
|
||||
this.listening = false;
|
||||
}
|
||||
}
|
||||
@@ -449,7 +456,7 @@ public final class TestMailServer {
|
||||
this.serverSocket.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error(IO_EXCEPTION, e);
|
||||
}
|
||||
this.exec.shutdownNow();
|
||||
}
|
||||
@@ -485,7 +492,7 @@ public final class TestMailServer {
|
||||
this.writer = new BufferedWriter(new OutputStreamWriter(this.socket.getOutputStream()));
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
LOGGER.error(IO_EXCEPTION, e);
|
||||
}
|
||||
doRun();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public final class Log4j2LevelAdjuster implements MethodRule {
|
||||
|
||||
@Override
|
||||
public Statement apply(final Statement base, final FrameworkMethod method, Object target) {
|
||||
return new Statement() {
|
||||
class AdjustingStatement extends Statement {
|
||||
|
||||
@Override
|
||||
public void evaluate() throws Throwable {
|
||||
@@ -152,19 +152,19 @@ public final class Log4j2LevelAdjuster implements MethodRule {
|
||||
ctx.updateLoggers();
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
return new AdjustingStatement();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the classes for logging level adjusting configured before.
|
||||
* A new copy Log4j2LevelAdjuster instance is produced by this method.
|
||||
* The provided classes parameter overrides existing value in the {@link #classes}.
|
||||
* @param classes the classes to use for logging level adjusting
|
||||
* @param clazzes the classes to use for logging level adjusting
|
||||
* @return a Log4j2LevelAdjuster copy with the provided classes
|
||||
*/
|
||||
public Log4j2LevelAdjuster classes(Class<?>... classes) {
|
||||
return classes(false, classes);
|
||||
public Log4j2LevelAdjuster classes(Class<?>... clazzes) {
|
||||
return classes(false, clazzes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -172,13 +172,13 @@ public final class Log4j2LevelAdjuster implements MethodRule {
|
||||
* A new copy Log4j2LevelAdjuster instance is produced by this method.
|
||||
* The provided classes parameter can be merged with existing value in the {@link #classes}.
|
||||
* @param merge to merge or not with previously configured {@link #classes}
|
||||
* @param classes the classes to use for logging level adjusting
|
||||
* @param classesToAdjust the classes to use for logging level adjusting
|
||||
* @return a Log4j2LevelAdjuster copy with the provided classes
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public Log4j2LevelAdjuster classes(boolean merge, Class<?>... classes) {
|
||||
public Log4j2LevelAdjuster classes(boolean merge, Class<?>... classesToAdjust) {
|
||||
return new Log4j2LevelAdjuster(this.level,
|
||||
merge ? Stream.of(this.classes, classes).flatMap(Stream::of).toArray(Class<?>[]::new) : classes,
|
||||
merge ? Stream.of(this.classes, classesToAdjust).flatMap(Stream::of).toArray(Class<?>[]::new) : classesToAdjust,
|
||||
this.categories);
|
||||
}
|
||||
|
||||
@@ -186,11 +186,11 @@ public final class Log4j2LevelAdjuster implements MethodRule {
|
||||
* Specify the categories for logging level adjusting configured before.
|
||||
* A new copy Log4j2LevelAdjuster instance is produced by this method.
|
||||
* The provided categories parameter overrides existing value in the {@link #categories}.
|
||||
* @param categories the categories to use for logging level adjusting
|
||||
* @param categoriesToAdjust the categories to use for logging level adjusting
|
||||
* @return a Log4j2LevelAdjuster copy with the provided categories
|
||||
*/
|
||||
public Log4j2LevelAdjuster categories(String... categories) {
|
||||
return categories(false, categories);
|
||||
public Log4j2LevelAdjuster categories(String... categoriesToAdjust) {
|
||||
return categories(false, categoriesToAdjust);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user