8216363: NullPointerException in java.util.logging.Handler#isLoggable

The implementation is changed to match the spec: isLoggable(null) returns false.

Reviewed-by: mchung, lancea
This commit is contained in:
Daniel Fuchs 2019-02-21 16:57:47 +00:00
parent 7fd7a118da
commit e58a4da301
4 changed files with 103 additions and 6 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -329,12 +329,13 @@ public abstract class Handler {
* handler from logging the {@code LogRecord}. It will return false if
* the {@code LogRecord} is null.
*
* @param record a {@code LogRecord}
* @param record a {@code LogRecord} (may be null).
* @return true if the {@code LogRecord} would be logged.
*
*/
public boolean isLoggable(LogRecord record) {
final int levelValue = getLevel().intValue();
if (record == null) return false;
if (record.getLevel().intValue() < levelValue || levelValue == offValue) {
return false;
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -270,7 +270,7 @@ public class MemoryHandler extends Handler {
* check whether the {@code LogRecord} would result in a "push" of the
* buffer contents. It will return false if the {@code LogRecord} is null.
*
* @param record a {@code LogRecord}
* @param record a {@code LogRecord} (may be null).
* @return true if the {@code LogRecord} would be logged.
*
*/

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -225,7 +225,7 @@ public class StreamHandler extends Handler {
* whether it satisfies any {@code Filter}. It will also return false if
* no output stream has been assigned yet or the LogRecord is null.
*
* @param record a {@code LogRecord}
* @param record a {@code LogRecord} (may be null).
* @return true if the {@code LogRecord} would be logged.
*
*/