Skip to content

Commit

Permalink
Fix typos and add a nullability annotation.
Browse files Browse the repository at this point in the history
RELNOTES=n/a
PiperOrigin-RevId: 575377954
  • Loading branch information
java-team-github-bot authored and Flogger Team committed Oct 21, 2023
1 parent 5521e58 commit 13c94f8
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions api/src/main/java/com/google/common/flogger/MetadataKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import com.google.common.flogger.backend.Platform;
import java.util.Iterator;
import org.checkerframework.checker.nullness.compatqual.NullableDecl;

/**
* Key for logging semi-structured metadata values.
Expand All @@ -42,7 +43,7 @@
* be re-parsed by logs related tools).
* </ul>
*
* <p>If you just want to log an general "key value pair" in a small number of log statements, it is
* <p>If you just want to log a general "key value pair" in a small number of log statements, it is
* still better to just do something like {@code log("key=%s", value)}.
*
* <p>Metadata keys are expected to be singleton constants, and should never be allocated at the log
Expand All @@ -57,7 +58,7 @@
*
* <p>Custom subclasses of {@code MetadataKey} which override either of the protected {@link #emit}
* methods should take care to avoid calling any code which might trigger logging since this could
* lead to unexpected recusrion, especially if the key is being logged as part of a {@code
* lead to unexpected recursion, especially if the key is being logged as part of a {@code
* ScopedLoggingContext}. While there is protection against unbounded reentrant logging in Flogger,
* it is still best practice to avoid it where possible.
*
Expand Down Expand Up @@ -94,7 +95,7 @@ public class MetadataKey<T> {
*/
public interface KeyValueHandler {
/** Handle a single key/value pair of contextual metadata for a log statement. */
void handle(String key, Object value);
void handle(String key, @NullableDecl Object value);
}

/**
Expand Down Expand Up @@ -225,7 +226,7 @@ public final void safeEmitRepeated(Iterator<T> values, KeyValueHandler kvh) {
* <li>Calling any code which could log using the same {@code MetadataKey} instance (unless you
* implement protection against reentrant calling in this method).
* <li>Calling code which might block (e.g. performing file I/O or acquiring locks).
* <li>Allocating non-trivial amounds of memory (e.g. recording values in an unbounded data
* <li>Allocating non-trivial amounts of memory (e.g. recording values in an unbounded data
* structure).
* </ul>
*
Expand Down

0 comments on commit 13c94f8

Please sign in to comment.