Skip to content

Commit 0ade5b1

Browse files
committed
Replace log4j.Supplier by jdk’s in non-logging usage (#28812)
This commit replaces `org.apache.logging.log4j.util.Supplier` by `java.util.function.Supplier` in non-logging code. These usages are neither incorrect nor wrong but rather than accidental. I think our intention was to use the JDK's Supplier in these places.
1 parent 3b408d1 commit 0ade5b1

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

server/src/main/java/org/elasticsearch/action/search/SearchScrollAsyncAction.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.logging.log4j.Logger;
2323
import org.apache.logging.log4j.message.ParameterizedMessage;
24-
import org.apache.logging.log4j.util.Supplier;
2524
import org.elasticsearch.action.ActionListener;
2625
import org.elasticsearch.cluster.node.DiscoveryNode;
2726
import org.elasticsearch.cluster.node.DiscoveryNodes;
@@ -43,6 +42,7 @@
4342
import java.util.Set;
4443
import java.util.concurrent.atomic.AtomicInteger;
4544
import java.util.function.BiFunction;
45+
import java.util.function.Supplier;
4646

4747
import static org.elasticsearch.action.search.TransportSearchHelper.internalScrollSearchRequest;
4848

@@ -259,7 +259,7 @@ protected void onShardFailure(String phaseName, final CountDown counter, final l
259259
@Nullable SearchShardTarget searchShardTarget,
260260
Supplier<SearchPhase> nextPhaseSupplier) {
261261
if (logger.isDebugEnabled()) {
262-
logger.debug((Supplier<?>) () -> new ParameterizedMessage("[{}] Failed to execute {} phase", searchId, phaseName), failure);
262+
logger.debug(new ParameterizedMessage("[{}] Failed to execute {} phase", searchId, phaseName), failure);
263263
}
264264
addShardFailure(new ShardSearchFailure(failure, searchShardTarget));
265265
int successfulOperations = successfulOps.decrementAndGet();

server/src/main/java/org/elasticsearch/cluster/service/ClusterApplierService.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.logging.log4j.Logger;
2323
import org.apache.logging.log4j.message.ParameterizedMessage;
24-
import org.apache.logging.log4j.util.Supplier;
2524
import org.elasticsearch.cluster.ClusterChangedEvent;
2625
import org.elasticsearch.cluster.ClusterState;
2726
import org.elasticsearch.cluster.ClusterStateApplier;
@@ -61,6 +60,7 @@
6160
import java.util.concurrent.atomic.AtomicReference;
6261
import java.util.function.Consumer;
6362
import java.util.function.Function;
63+
import java.util.function.Supplier;
6464
import java.util.stream.Stream;
6565

6666
import static org.elasticsearch.cluster.service.ClusterService.CLUSTER_SERVICE_SLOW_TASK_LOGGING_THRESHOLD_SETTING;
@@ -401,8 +401,7 @@ protected void runTask(UpdateTask task) {
401401
} catch (Exception e) {
402402
TimeValue executionTime = TimeValue.timeValueMillis(Math.max(0, TimeValue.nsecToMSec(currentTimeInNanos() - startTimeNS)));
403403
if (logger.isTraceEnabled()) {
404-
logger.trace(
405-
(Supplier<?>) () -> new ParameterizedMessage(
404+
logger.trace(new ParameterizedMessage(
406405
"failed to execute cluster state applier in [{}], state:\nversion [{}], source [{}]\n{}{}{}",
407406
executionTime,
408407
previousClusterState.version(),
@@ -441,7 +440,7 @@ protected void runTask(UpdateTask task) {
441440
final String stateUUID = newClusterState.stateUUID();
442441
final String fullState = newClusterState.toString();
443442
logger.warn(
444-
(Supplier<?>) () -> new ParameterizedMessage(
443+
(org.apache.logging.log4j.util.Supplier<?>) () -> new ParameterizedMessage(
445444
"failed to apply updated cluster state in [{}]:\nversion [{}], uuid [{}], source [{}]\n{}",
446445
executionTime,
447446
version,
@@ -528,8 +527,7 @@ public void onFailure(String source, Exception e) {
528527
listener.onFailure(source, e);
529528
} catch (Exception inner) {
530529
inner.addSuppressed(e);
531-
logger.error(
532-
(Supplier<?>) () -> new ParameterizedMessage(
530+
logger.error(new ParameterizedMessage(
533531
"exception thrown by listener notifying of failure from [{}]", source), inner);
534532
}
535533
}
@@ -539,12 +537,10 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
539537
try {
540538
listener.clusterStateProcessed(source, oldState, newState);
541539
} catch (Exception e) {
542-
logger.error(
543-
(Supplier<?>) () -> new ParameterizedMessage(
540+
logger.error(new ParameterizedMessage(
544541
"exception thrown by listener while notifying of cluster state processed from [{}], old cluster state:\n" +
545542
"{}\nnew cluster state:\n{}",
546-
source, oldState, newState),
547-
e);
543+
source, oldState, newState), e);
548544
}
549545
}
550546
}

0 commit comments

Comments
 (0)