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:
Gary Russell
2019-04-30 13:57:13 -04:00
committed by Artem Bilan
parent 4199ff57cd
commit 0bb901b286
19 changed files with 280 additions and 235 deletions

View File

@@ -47,8 +47,8 @@ public class MessageGroupExpiredEvent extends IntegrationEvent {
super(source);
this.groupId = groupId;
this.messageCount = messageCount;
this.lastModified = lastModified;
this.expired = expired;
this.lastModified = (Date) lastModified.clone();
this.expired = (Date) expired.clone();
this.discarded = discarded;
}

View File

@@ -163,7 +163,7 @@ public class MessagingGatewayRegistrar implements ImportBeanDefinitionRegistrar
}
String id = (String) gatewayAttributes.get("name");
if (!StringUtils.hasText(id)) {
id = Introspector.decapitalize(serviceInterface.substring(serviceInterface.lastIndexOf(".") + 1));
id = Introspector.decapitalize(serviceInterface.substring(serviceInterface.lastIndexOf('.') + 1));
}
gatewayProxyBuilder.addConstructorArgValue(serviceInterface);

View File

@@ -35,42 +35,49 @@ import org.springframework.util.xml.DomUtils;
*
* @author Mark Fisher
* @author Artem Bilan
* @author Gary Russell
*/
public class AnnotationConfigParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(final Element element, ParserContext parserContext) {
StandardAnnotationMetadata importingClassMetadata =
new StandardAnnotationMetadata(Object.class) {
@Override
public Map<String, Object> getAnnotationAttributes(String annotationType) {
if (EnablePublisher.class.getName().equals(annotationType)) {
Element enablePublisherElement =
DomUtils.getChildElementByTagName(element, "enable-publisher");
if (enablePublisherElement != null) {
Map<String, Object> attributes = new HashMap<>();
attributes.put("defaultChannel",
enablePublisherElement.getAttribute("default-publisher-channel"));
attributes.put("proxyTargetClass",
enablePublisherElement.getAttribute("proxy-target-class"));
attributes.put("order", enablePublisherElement.getAttribute("order"));
return attributes;
}
else {
return null;
}
}
else {
return null;
}
}
};
new IntegrationRegistrar().registerBeanDefinitions(importingClassMetadata, parserContext.getRegistry());
new IntegrationRegistrar().registerBeanDefinitions(new ExtendedAnnotationMetadata(Object.class, element),
parserContext.getRegistry());
return null;
}
private static final class ExtendedAnnotationMetadata extends StandardAnnotationMetadata {
private final Element element;
ExtendedAnnotationMetadata(Class<?> introspectedClass, Element element) {
super(introspectedClass);
this.element = element;
}
@Override
public Map<String, Object> getAnnotationAttributes(String annotationType) {
if (EnablePublisher.class.getName().equals(annotationType)) {
Element enablePublisherElement =
DomUtils.getChildElementByTagName(this.element, "enable-publisher");
if (enablePublisherElement != null) {
Map<String, Object> attributes = new HashMap<>();
attributes.put("defaultChannel",
enablePublisherElement.getAttribute("default-publisher-channel"));
attributes.put("proxyTargetClass",
enablePublisherElement.getAttribute("proxy-target-class"));
attributes.put("order", enablePublisherElement.getAttribute("order"));
return attributes;
}
else {
return null;
}
}
else {
return null;
}
}
}
}

View File

@@ -132,38 +132,7 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
if (this.lifecycleDelegate != null) {
this.lifecycleDelegate.start();
}
this.publisher.subscribe(new BaseSubscriber<Message<?>>() {
private final Subscriber<Message<?>> delegate = ReactiveStreamsConsumer.this.subscriber;
@Override
public void hookOnSubscribe(Subscription s) {
this.delegate.onSubscribe(s);
ReactiveStreamsConsumer.this.subscription = s;
}
@Override
public void hookOnNext(Message<?> message) {
try {
this.delegate.onNext(message);
}
catch (Exception e) {
ReactiveStreamsConsumer.this.errorHandler.handleError(e);
hookOnError(e);
}
}
@Override
public void hookOnError(Throwable t) {
this.delegate.onError(t);
}
@Override
public void hookOnComplete() {
this.delegate.onComplete();
}
});
this.publisher.subscribe(new DelegatingSubscriber());
}
@Override
@@ -176,6 +145,42 @@ public class ReactiveStreamsConsumer extends AbstractEndpoint implements Integra
}
}
private final class DelegatingSubscriber extends BaseSubscriber<Message<?>> {
private final Subscriber<Message<?>> delegate = ReactiveStreamsConsumer.this.subscriber;
DelegatingSubscriber() {
super();
}
@Override
public void hookOnSubscribe(Subscription s) {
this.delegate.onSubscribe(s);
ReactiveStreamsConsumer.this.subscription = s;
}
@Override
public void hookOnNext(Message<?> message) {
try {
this.delegate.onNext(message);
}
catch (Exception e) {
ReactiveStreamsConsumer.this.errorHandler.handleError(e);
hookOnError(e);
}
}
@Override
public void hookOnError(Throwable t) {
this.delegate.onError(t);
}
@Override
public void hookOnComplete() {
this.delegate.onComplete();
}
}
private static final class MessageHandlerSubscriber
implements CoreSubscriber<Message<?>>, Disposable, Lifecycle {

View File

@@ -465,7 +465,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
}
@Nullable
protected Object doInvoke(MethodInvocation invocation, boolean runningOnCallerThread) throws Throwable {
protected Object doInvoke(MethodInvocation invocation, boolean runningOnCallerThread) throws Throwable { // NOSONAR
Method method = invocation.getMethod();
if (AopUtils.isToStringMethod(method)) {
return "gateway proxy for service interface [" + this.serviceInterface + "]";
@@ -474,7 +474,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
return invokeGatewayMethod(invocation, runningOnCallerThread);
}
catch (Throwable e) { //NOSONAR - ok to catch, rethrown below
this.rethrowExceptionCauseIfPossible(e, invocation.getMethod());
rethrowExceptionCauseIfPossible(e, invocation.getMethod());
return null; // preceding call should always throw something
}
}
@@ -538,7 +538,7 @@ public class GatewayProxyFactoryBean extends AbstractEndpoint
return (response != null) ? this.convert(response, returnType) : null;
}
private void rethrowExceptionCauseIfPossible(Throwable originalException, Method method) throws Throwable {
private void rethrowExceptionCauseIfPossible(Throwable originalException, Method method) throws Throwable { // NOSONAR
Class<?>[] exceptionTypes = method.getExceptionTypes();
Throwable t = originalException;
while (t != null) {

View File

@@ -19,8 +19,6 @@ package org.springframework.integration.handler.advice;
import java.lang.reflect.Method;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.messaging.Message;
@@ -37,10 +35,8 @@ import org.springframework.messaging.MessageHandler;
*/
public abstract class AbstractHandleMessageAdvice extends IntegrationObjectSupport implements HandleMessageAdvice {
protected final Log logger = LogFactory.getLog(this.getClass());
@Override
public final Object invoke(MethodInvocation invocation) throws Throwable {
public final Object invoke(MethodInvocation invocation) throws Throwable { // NOSONAR
Method method = invocation.getMethod();
Object invocationThis = invocation.getThis();
Object[] arguments = invocation.getArguments();

View File

@@ -64,42 +64,7 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
else {
Message<?> message = (Message<?>) arguments[0];
try {
return doInvoke(new ExecutionCallback() {
@Override
public Object execute() {
try {
return invocation.proceed();
}
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}
@Override
public Object cloneAndExecute() {
try {
/*
* If we don't copy the invocation carefully it won't keep a reference to the other
* interceptors in the chain.
*/
if (invocation instanceof ProxyMethodInvocation) {
return ((ProxyMethodInvocation) invocation).invocableClone().proceed();
}
else {
throw new IllegalStateException(
"MethodInvocation of the wrong type detected - this should not happen with Spring AOP," +
" so please raise an issue if you see this exception");
}
}
catch (Exception e) { //NOSONAR - catch necessary so we can wrap Errors
throw new MessagingException(message, "Failed to handle", e);
}
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}
}, invocationThis, message);
return doInvoke(new CallbackImpl(invocation), invocationThis, message);
}
catch (Exception e) {
throw this.unwrapThrowableIfNecessary(e);
@@ -172,6 +137,50 @@ public abstract class AbstractRequestHandlerAdvice extends IntegrationObjectSupp
}
private static final class CallbackImpl implements ExecutionCallback {
private final MethodInvocation invocation;
CallbackImpl(MethodInvocation invocation) {
this.invocation = invocation;
}
@Override
public Object execute() {
try {
return this.invocation.proceed();
}
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}
@Override
public Object cloneAndExecute() {
try {
/*
* If we don't copy the invocation carefully it won't keep a reference to the other
* interceptors in the chain.
*/
if (this.invocation instanceof ProxyMethodInvocation) {
return ((ProxyMethodInvocation) this.invocation).invocableClone().proceed();
}
else {
throw new IllegalStateException(
"MethodInvocation of the wrong type detected - this should not happen with Spring AOP," +
" so please raise an issue if you see this exception");
}
}
catch (Exception e) { //NOSONAR - catch necessary so we can wrap Errors
throw new MessagingException((Message<?>) this.invocation.getArguments()[0], "Failed to handle", e);
}
catch (Throwable e) { //NOSONAR - ok to catch; unwrapped and rethrown below
throw new ThrowableHolderException(e);
}
}
}
@SuppressWarnings("serial")
protected static final class ThrowableHolderException extends RuntimeException {

View File

@@ -93,11 +93,13 @@ public class PropertiesPersistingMetadataStore implements ConcurrentMetadataStor
@Override
public void afterPropertiesSet() {
File baseDir = new File(this.baseDirectory);
baseDir.mkdirs();
if (!baseDir.mkdirs() && this.logger.isWarnEnabled()) {
this.logger.warn("Failed to create directories for " + baseDir);
}
this.file = new File(baseDir, this.fileName);
try {
if (!this.file.exists()) {
this.file.createNewFile();
if (!this.file.exists() && !this.file.createNewFile() && this.logger.isWarnEnabled()) {
this.logger.warn("Failed to create file " + this.file);
}
}
catch (Exception e) {

View File

@@ -21,44 +21,59 @@ import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
/**
* The {@link LockRegistry} implementation which has no effect. Mainly used in cases where locking itself must be conditional
* but an extra IF statement would clutter the code.
* For example. In the FILE module FileWritingMessageHandler is initialized with this instance of LockRegistry by default
* since real locking is only required if its 'append' flag is set to true.
* The {@link LockRegistry} implementation which has no effect. Mainly used in cases where
* locking itself must be conditional but an extra IF statement would clutter the code.
* For example. In the FILE module FileWritingMessageHandler is initialized with this
* instance of LockRegistry by default since real locking is only required if its 'append'
* flag is set to true.
*
* @author Oleg Zhurakousky
* @author Gary Russell
* @since 2.2
*
*/
public final class PassThruLockRegistry implements LockRegistry {
@Override
public Lock obtain(Object lockKey) {
return new Lock() {
public void unlock() {
// noop
}
public boolean tryLock(long time, TimeUnit unit)
throws InterruptedException {
return true;
}
public boolean tryLock() {
return true;
}
public Condition newCondition() {
throw new UnsupportedOperationException("This method is not supported for this implementation of Lock");
}
public void lockInterruptibly() throws InterruptedException {
// noop
}
public void lock() {
// noop
}
};
return new PassThruLock();
}
private static final class PassThruLock implements Lock {
PassThruLock() {
super();
}
@Override
public void unlock() {
// noop
}
@Override
public boolean tryLock(long time, TimeUnit unit) {
return true;
}
@Override
public boolean tryLock() {
return true;
}
@Override
public Condition newCondition() {
throw new UnsupportedOperationException("This method is not supported for this implementation of Lock");
}
@Override
public void lockInterruptibly() {
// noop
}
@Override
public void lock() {
// noop
}
}
}

View File

@@ -685,10 +685,10 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
* nothing.
* @param remoteFileOperations the remote file template.
* @param path the path.
* @param chmod the chmod to set.
* @param chmodToSet the chmod to set.
* @since 4.3
*/
protected void doChmod(RemoteFileOperations<F> remoteFileOperations, String path, int chmod) {
protected void doChmod(RemoteFileOperations<F> remoteFileOperations, String path, int chmodToSet) {
// no-op
}
@@ -921,7 +921,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
outputStream = new BufferedOutputStream(new FileOutputStream(tempFile));
}
if (replacing) {
localFile.delete();
if (!localFile.delete() && this.logger.isWarnEnabled()) {
this.logger.warn("Failed to delete " + localFile);
}
}
try {
session.read(remoteFilePath, outputStream);
@@ -944,7 +946,7 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
try {
outputStream.close();
}
catch (Exception ignored2) {
catch (@SuppressWarnings("unused") Exception ignored2) {
//Ignore it
}
}
@@ -953,7 +955,9 @@ public abstract class AbstractRemoteFileOutboundGateway<F> extends AbstractReply
}
if (this.options.contains(Option.PRESERVE_TIMESTAMP)
|| FileExistsMode.REPLACE_IF_MODIFIED.equals(existsMode)) {
localFile.setLastModified(getModified(fileInfo));
if (!localFile.setLastModified(getModified(fileInfo)) && this.logger.isWarnEnabled()) {
logger.warn("Failed to set lastModified on " + localFile);
}
}
if (this.options.contains(Option.DELETE)) {
boolean result = session.remove(remoteFilePath);

View File

@@ -181,7 +181,9 @@ public abstract class AbstractInboundFileSynchronizingMessageSource<F>
if (logger.isDebugEnabled()) {
logger.debug("The '" + this.localDirectory + "' directory doesn't exist; Will create.");
}
this.localDirectory.mkdirs();
if (!this.localDirectory.mkdirs() && this.logger.isWarnEnabled()) {
this.logger.warn("Failed to create directories for " + this.localDirectory);
}
}
else {
throw new FileNotFoundException(this.localDirectory.getName());

View File

@@ -58,30 +58,30 @@ public class CachingClientConnectionFactory extends AbstractClientConnectionFact
// override single-use to true so the target creates multiple connections
target.setSingleUse(true);
this.targetConnectionFactory = target;
this.pool = new SimplePool<TcpConnectionSupport>(poolSize,
new SimplePool.PoolItemCallback<TcpConnectionSupport>() {
class Callback implements SimplePool.PoolItemCallback<TcpConnectionSupport> {
@Override
public TcpConnectionSupport createForPool() {
try {
return CachingClientConnectionFactory.this.targetConnectionFactory.getConnection();
}
catch (Exception e) {
throw new MessagingException("Failed to obtain connection", e);
}
}
@Override
public TcpConnectionSupport createForPool() {
try {
return CachingClientConnectionFactory.this.targetConnectionFactory.getConnection();
}
catch (Exception e) {
throw new MessagingException("Failed to obtain connection", e);
}
}
@Override
public boolean isStale(TcpConnectionSupport connection) {
return !connection.isOpen();
}
@Override
public boolean isStale(TcpConnectionSupport connection) {
return !connection.isOpen();
}
@Override
public void removedFromPool(TcpConnectionSupport connection) {
connection.close();
}
@Override
public void removedFromPool(TcpConnectionSupport connection) {
connection.close();
}
});
}
this.pool = new SimplePool<TcpConnectionSupport>(poolSize, new Callback());
}
/**

View File

@@ -141,8 +141,8 @@ public class RedisChannelPriorityMessageStore extends RedisChannelMessageStore
for (Object key : keys) {
Assert.isInstanceOf(String.class, key);
String keyString = (String) key;
int lastIndexOfColon = keyString.lastIndexOf(":");
if (keyString.indexOf(":") != lastIndexOfColon) {
int lastIndexOfColon = keyString.lastIndexOf(':');
if (keyString.indexOf(':') != lastIndexOfColon) {
narrowedKeys.add(keyString.substring(0, lastIndexOfColon));
}
else {

View File

@@ -185,12 +185,6 @@ public class RSocketOutboundGateway extends AbstractReplyProducingMessageHandler
}
}
@Override
public void destroy() {
super.destroy();
}
@Override
protected Object handleRequestMessage(Message<?> requestMessage) {
RSocketRequester rsocketRequester = requestMessage.getHeaders()

View File

@@ -53,7 +53,8 @@ public final class ChannelSecurityInterceptor extends AbstractSecurityIntercepto
}
public Object invoke(MethodInvocation invocation) throws Throwable {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable { // NOSONAR
Method method = invocation.getMethod();
if (method.getName().equals("send") || method.getName().equals("receive")) {
return this.invokeWithAuthorizationCheck(invocation);
@@ -61,7 +62,7 @@ public final class ChannelSecurityInterceptor extends AbstractSecurityIntercepto
return invocation.proceed();
}
private Object invokeWithAuthorizationCheck(MethodInvocation methodInvocation) throws Throwable {
private Object invokeWithAuthorizationCheck(MethodInvocation methodInvocation) throws Throwable { // NOSONAR
Object returnValue = null;
InterceptorStatusToken token = super.beforeInvocation(new ChannelInvocation(methodInvocation));
try {

View File

@@ -208,37 +208,38 @@ public class StompInboundChannelAdapter extends MessageProducerSupport implement
private void subscribeDestination(final String destination) {
if (this.stompSession != null) {
class FrameHandler implements StompFrameHandler {
@Override
public Type getPayloadType(StompHeaders headers) {
return StompInboundChannelAdapter.this.payloadType;
}
@Override
public void handleFrame(StompHeaders headers, @Nullable Object body) {
Message<?> message;
if (body == null) {
logger.info("No body in STOMP frame: nothing to produce.");
return;
}
else if (body instanceof Message) {
message = (Message<?>) body;
}
else {
message =
getMessageBuilderFactory()
.withPayload(body)
.copyHeaders(
StompInboundChannelAdapter.this.headerMapper.toHeaders(headers))
.build();
}
sendMessage(message);
}
}
final StompSession.Subscription subscription =
this.stompSession.subscribe(destination, new StompFrameHandler() {
@Override
public Type getPayloadType(StompHeaders headers) {
return StompInboundChannelAdapter.this.payloadType;
}
@Override
public void handleFrame(StompHeaders headers, @Nullable Object body) {
Message<?> message;
if (body == null) {
logger.info("No body in STOMP frame: nothing to produce.");
return;
}
else if (body instanceof Message) {
message = (Message<?>) body;
}
else {
message =
getMessageBuilderFactory()
.withPayload(body)
.copyHeaders(
StompInboundChannelAdapter.this.headerMapper.toHeaders(headers))
.build();
}
sendMessage(message);
}
});
this.stompSession.subscribe(destination, new FrameHandler());
if (this.stompSessionManager.isAutoReceiptEnabled()) {
final ApplicationEventPublisher eventPublisher = this.applicationEventPublisher;

View File

@@ -80,21 +80,23 @@ public class StompHeaderMapper implements HeaderMapper<StompHeaders> {
private String[] outboundHeaderNames = STOMP_OUTBOUND_HEADER_NAMES;
public void setInboundHeaderNames(String[] inboundHeaderNames) { //NOSONAR - false positive
public void setInboundHeaderNames(String[] inboundHeaderNames) {
Assert.notNull(inboundHeaderNames, "'inboundHeaderNames' must not be null.");
Assert.noNullElements(inboundHeaderNames, "'inboundHeaderNames' must not contains null elements.");
Arrays.sort(inboundHeaderNames);
String[] copy = Arrays.copyOf(inboundHeaderNames, inboundHeaderNames.length);
Arrays.sort(copy);
if (!Arrays.equals(STOMP_INBOUND_HEADER_NAMES, inboundHeaderNames)) {
this.inboundHeaderNames = inboundHeaderNames;
this.inboundHeaderNames = copy;
}
}
public void setOutboundHeaderNames(String[] outboundHeaderNames) { //NOSONAR - false positive
public void setOutboundHeaderNames(String[] outboundHeaderNames) {
Assert.notNull(outboundHeaderNames, "'outboundHeaderNames' must not be null.");
Assert.noNullElements(outboundHeaderNames, "'outboundHeaderNames' must not contains null elements.");
Arrays.sort(outboundHeaderNames);
String[] copy = Arrays.copyOf(outboundHeaderNames, outboundHeaderNames.length);
Arrays.sort(copy);
if (!Arrays.equals(STOMP_OUTBOUND_HEADER_NAMES, outboundHeaderNames)) {
this.outboundHeaderNames = outboundHeaderNames;
this.outboundHeaderNames = copy;
}
}

View File

@@ -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();
}

View File

@@ -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);
}
/**