Skip to content

Commit

Permalink
fix SLF4J-485, LoggingEventBuilder addArgument() should take Supplier…
Browse files Browse the repository at this point in the history
…<?>, not Supplier<Object>
  • Loading branch information
ceki committed Jun 15, 2021
1 parent a405c8d commit 5fb5ecb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Expand Up @@ -45,7 +45,7 @@ public LoggingEventBuilder addArgument(Object p) {
}

@Override
public LoggingEventBuilder addArgument(Supplier<Object> objectSupplier) {
public LoggingEventBuilder addArgument(Supplier<?> objectSupplier) {
loggingEvent.addArgument(objectSupplier.get());
return this;
}
Expand Down
Expand Up @@ -19,7 +19,7 @@ public interface LoggingEventBuilder {

LoggingEventBuilder addArgument(Object p);

LoggingEventBuilder addArgument(Supplier<Object> objectSupplier);
LoggingEventBuilder addArgument(Supplier<?> objectSupplier);

LoggingEventBuilder addKeyValue(String key, Object value);

Expand Down
Expand Up @@ -31,7 +31,7 @@ public LoggingEventBuilder addArgument(Object p) {
}

@Override
public LoggingEventBuilder addArgument(Supplier<Object> objectSupplier) {
public LoggingEventBuilder addArgument(Supplier<?> objectSupplier) {
return singleton();
}

Expand Down
Expand Up @@ -86,11 +86,12 @@ public void messageWithTwoArguments() {
assertLogMessage("Temperature set to 16. Old temperature was 15.", 0);
}
}


@Test
public void supplierArguments() {
Supplier<String> stringSupplier = () -> "String";
logger.atDebug().addArgument(stringSupplier).log("hello");

Supplier<String> stringSupplier = () -> "world";
logger.atInfo().addArgument(stringSupplier).log("hello {}");
assertLogMessage("hello world", 0);
}

public int t16() {
Expand Down

0 comments on commit 5fb5ecb

Please sign in to comment.