United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4625722 : java.util.logging.Level(null, int[, String]) doesn't throw NPE

Details
Type:
Bug
Submit Date:
2002-01-18
Status:
Closed
Updated Date:
2004-09-14
Project Name:
JDK
Resolved Date:
2003-08-30
Component:
core-libs
OS:
solaris_7,generic
Sub-Component:
java.util.logging
CPU:
sparc,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.4.0,5.0
Fixed Versions:
5.0 (tiger)

Related Reports

Sub Tasks

Description
Name: sdR10048			Date: 01/18/2002


JDK1.4rc91 constuctor

protected java.util.logging.Level(String name,
                                  int value,
                                  String resourceBundleName)

does not throw NullPointerException if 'name' == null.

Level(String, int) has the same problem.

Package level spec for java.util.logging says:
----------
Null Pointers

In general, unless otherwise noted in the javadoc, methods and
contructors will throw NullPointerException if passed a null
argument.

The one broad exception to this rule is that the logging
convenience methods in the Logger class (the log, logp, log, severe,
warning, config, fine, finer, and finest methods) will accept null
values for all arguments except for the initial Level argument (if
any).

Consturctor spec says:
----------
protected Level(String name,
                int value,
                String resourceBundleName)

Create a named Level with a given integer value and a given localization resource name.

Parameters:
  name - the name of the Level, for example "SEVERE".
  value - an integer value for the level.
  resourceBundleName - name of a resource bundle to use in localizing
                       the given name (may be null). 

Demo test:
----------
import java.util.logging.*;

public class Test extends Level {

    public Test(String name, int value) {
        super(name, value);
    }

    public Test(String name, int value, String resourceBundleName) {
        super(name, value, resourceBundleName);
    }

    public static void main(String[] args) {
        try {
            new Test(null, 1, "");
            System.out.println("No NPE.");
        } catch (NullPointerException e) {
            System.out.println( "NPE." );
        }
    }

}

Demo output:
----------
[archer] ~/tmp
% /set/jdk-builds/JDK1.4.0rc-b91/solaris/bin/java Test
No NPE.
        
======================================================================
###@###.### 2004-09-14

                                    

Comments
CONVERTED DATA

BugTraq+ Release Management Values

COMMIT TO FIX:
tiger

FIXED IN:
tiger

INTEGRATED IN:
tiger
tiger-b18

VERIFIED IN:
1.5


                                     
2004-09-15
EVALUATION

^C

###@###.### 2002-05-28

The analysis is correct
###@###.### 2003-07-23

New specification through CCC is
/**
     * Create a named Level with a given integer value and a
     * given localization resource name.
     * <p>
     * @param name  the name of the Level, for example "SEVERE".
     * @param value an integer value for the level.
     * @param resourceBundleName name of a resource bundle to use in
     *    localizing the given name (may be null).
     * @throws NullPointerException if the name is null
     */
    protected Level(String name, int value, String resourceBundleName) {

###@###.### 2003-09-09
                                     
2003-09-09



Hardware and Software, Engineered to Work Together