From 2141ffab20f453b005b425d9ded7d523301f6ec6 Mon Sep 17 00:00:00 2001 From: Flogger Team Date: Wed, 15 May 2024 11:11:59 -0700 Subject: [PATCH] Add missing `@NullableDecl` to LogData.getTemplateContext() and .getLoggerName() Fixes #381 . Tested: % bazel test :api_tests RELNOTES=Updates nullability for LogData PiperOrigin-RevId: 634014539 --- .../main/java/com/google/common/flogger/LogContext.java | 1 + .../java/com/google/common/flogger/backend/LogData.java | 7 +++++-- .../com/google/common/flogger/testing/FakeLogData.java | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/api/src/main/java/com/google/common/flogger/LogContext.java b/api/src/main/java/com/google/common/flogger/LogContext.java index 606afc21..76b0133f 100644 --- a/api/src/main/java/com/google/common/flogger/LogContext.java +++ b/api/src/main/java/com/google/common/flogger/LogContext.java @@ -426,6 +426,7 @@ public final LogSite getLogSite() { } @Override + @NullableDecl public final TemplateContext getTemplateContext() { return templateContext; } diff --git a/api/src/main/java/com/google/common/flogger/backend/LogData.java b/api/src/main/java/com/google/common/flogger/backend/LogData.java index 1fcaf2e0..adc6dbe3 100644 --- a/api/src/main/java/com/google/common/flogger/backend/LogData.java +++ b/api/src/main/java/com/google/common/flogger/backend/LogData.java @@ -18,6 +18,7 @@ import com.google.common.flogger.LogSite; import java.util.logging.Level; +import org.checkerframework.checker.nullness.compatqual.NullableDecl; /** * A backend API for determining metadata associated with a log statement. @@ -46,6 +47,7 @@ public interface LogData { * Returns the logger name (which is usually a canonicalized class name) or {@code null} if not * given. */ + @NullableDecl String getLoggerName(); /** @@ -95,9 +97,10 @@ public interface LogData { /** * Returns a template key for this log statement, or {@code null} if the statement does not - * require formatting (in which case the message to be logged can be determined by calling - * {@link #getLiteralArgument()}). + * require formatting (in which case the message to be logged can be determined by calling* {@link + * #getLiteralArgument()}). */ + @NullableDecl TemplateContext getTemplateContext(); /** diff --git a/api/src/test/java/com/google/common/flogger/testing/FakeLogData.java b/api/src/test/java/com/google/common/flogger/testing/FakeLogData.java index d319746c..9cca9790 100644 --- a/api/src/test/java/com/google/common/flogger/testing/FakeLogData.java +++ b/api/src/test/java/com/google/common/flogger/testing/FakeLogData.java @@ -30,6 +30,7 @@ import com.google.common.flogger.parser.MessageParser; import com.google.errorprone.annotations.CanIgnoreReturnValue; import java.util.logging.Level; +import org.checkerframework.checker.nullness.compatqual.NullableDecl; /** * A mutable fake {@link LogData} implementation to help test logging backends and other log @@ -143,6 +144,7 @@ public boolean wasForced() { } @Override + @NullableDecl public TemplateContext getTemplateContext() { return context; }