mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 20:17:51 +02:00
Do not create a logger during initialization in CidrAddressBlock
This is patched from [] We should have done this when we migrated to Flogger. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=219860046
This commit is contained in:
parent
9ce07db38a
commit
9b10c116f3
1 changed files with 11 additions and 2 deletions
|
@ -41,7 +41,16 @@ import javax.annotation.Nullable;
|
|||
// TODO(b/21870796): Migrate to Guava version when this is open-sourced.
|
||||
public class CidrAddressBlock implements Iterable<InetAddress>, Serializable {
|
||||
|
||||
/**
|
||||
* Wrapper class around a logger instance for {@link CidrAddressBlock}.
|
||||
*
|
||||
* <p>We don't want to have a static instance of {@link Logger} in {@link CidrAddressBlock},
|
||||
* because that can cause a race condition, since the logging subsystem might not yet be
|
||||
* initialized. With this wrapper, the {@link Logger} will be initialized on first use.
|
||||
*/
|
||||
static class CidrAddressBlockLogger {
|
||||
private static final FluentLogger logger = FluentLogger.forEnclosingClass();
|
||||
}
|
||||
|
||||
private final InetAddress ip;
|
||||
|
||||
|
@ -343,7 +352,7 @@ public class CidrAddressBlock implements Iterable<InetAddress>, Serializable {
|
|||
// not have been created with an invalid netmask and a valid
|
||||
// netmask should have been successfully applied to "ipAddr" as long
|
||||
// as it represents an address of the same family as "this.ip".
|
||||
logger.atWarning().withCause(e).log("Error while applying netmask.");
|
||||
CidrAddressBlockLogger.logger.atWarning().withCause(e).log("Error while applying netmask.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue