Skip to content

Commit ba4d4b6

Browse files
committed
fixed copilot comments
1 parent 5fc5891 commit ba4d4b6

4 files changed

Lines changed: 17 additions & 2 deletions

File tree

client/src/main/java/com/microsoft/durabletask/ReplaySafeLogger.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
*
1919
* <p>This mirrors the {@code ReplaySafeLogger} nested class in the modern .NET
2020
* {@code TaskOrchestrationContext}.
21+
*
22+
* <p><b>Note on overloads:</b> The {@code (String, Object, Object)} and {@code (String, Object...)}
23+
* overloads at each log level are both defined by the {@link Logger} interface. SLF4J provides the
24+
* explicit 2-arg overload to avoid varargs array allocation in the common case. Java's overload
25+
* resolution (JLS §15.12.2) always prefers the non-varargs form, so dispatch is unambiguous despite
26+
* the apparent overlap. This wrapper delegates each overload to the identical overload on the inner
27+
* logger.
2128
*/
2229
final class ReplaySafeLogger implements Logger {
2330

client/src/main/java/com/microsoft/durabletask/ReplaySafeLoggerFactory.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ ILoggerFactory underlying() {
3131

3232
@Override
3333
public Logger getLogger(String name) {
34+
Helpers.throwIfArgumentNullOrWhiteSpace(name, "name");
3435
return new ReplaySafeLogger(context, ReplaySafeLoggers.unwrap(context).getLogger(name));
3536
}
3637
}

client/src/main/java/com/microsoft/durabletask/ReplaySafeLoggers.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ private ReplaySafeLoggers() {
3333
static ILoggerFactory unwrap(TaskOrchestrationContext context) {
3434
Helpers.throwIfArgumentNull(context, "context");
3535
ILoggerFactory factory = context.getLoggerFactory();
36+
if (factory == null) {
37+
throw new IllegalStateException(
38+
"getLoggerFactory() returned null. Ensure the context's getLoggerFactory() " +
39+
"implementation returns a non-null ILoggerFactory.");
40+
}
3641
int depth = 0;
3742
while (factory instanceof ReplaySafeLoggerFactory) {
3843
if (++depth > MAX_UNWRAP_DEPTH) {

client/src/main/java/com/microsoft/durabletask/TaskOrchestrationContext.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,18 +892,20 @@ default ILoggerFactory getLoggerFactory() {
892892
* @return a replay-safe SLF4J {@code Logger}
893893
*/
894894
default Logger createReplaySafeLogger(String name) {
895+
Helpers.throwIfArgumentNullOrWhiteSpace(name, "name");
895896
return new ReplaySafeLogger(this, ReplaySafeLoggers.unwrap(this).getLogger(name));
896897
}
897898

898899
/**
899900
* Returns an SLF4J {@link Logger} that is replay-safe, using the fully-qualified class name
900901
* as the logger category.
901902
*
902-
* @param clazz the class whose name to use as the logger category
903+
* @param class the class whose name to use as the logger category
903904
* @return a replay-safe SLF4J {@code Logger}
904905
* @see #createReplaySafeLogger(String)
905906
*/
906-
default Logger createReplaySafeLogger(Class<?> clazz) {
907+
default Logger createReplaySafeLogger(Class<?> class) {
908+
Helpers.throwIfArgumentNull(class, "class");
907909
return new ReplaySafeLogger(this, ReplaySafeLoggers.unwrap(this).getLogger(clazz.getName()));
908910
}
909911

0 commit comments

Comments
 (0)