Name: sdR10048 Date: 10/10/2003
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta-b22"
JCK : 1.5
Platform[s] : Solaris
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] :
api/java_util/logging/StreamHandler/index.html#IsLoggable[StreamHandler0013_15]
api/java_util/logging/StreamHandler/index.html#Publish[StreamHandler0004_15]
Specification excerpt:
======================
--------- J2SE API spec v.1.5 ---------
...
public boolean isLoggable(LogRecord record)
Check if this Handler would actually log a given LogRecord.
This method checks if the LogRecord has an appropriate level and whether
it satisfies any Filter. It will also return false if no output stream has been
assigned yet or the LogRecord is Null.
Overrides:
isLoggable in class Handler
Parameters:
record - a LogRecord
Returns:
true if the LogRecord would be logged.
===
public void publish(LogRecord record)
Format and publish a LogRecord.
The StreamHandler first checks if there is an OutputStream and if the given LogRecord has at least the required log level. If not it silently returns. If so, it calls any associated Filter to check if the record should be published. If so, it calls its Formatter to format the record and then writes the result to the current output stream.
If this is the first LogRecord to be written to a given OutputStream, the
Formatter's "head" string is written to the stream before the LogRecord
is written.
Specified by:
publish in class Handler
Parameters:
record - description of the log event. A null record is silently ignored and
is not published
...
---------- end-of-excerpt ---------------
Problem description
===================
The two designated methods react wrong on null input param.
They do throw NullPointerException, this is not what spec says.
See demo.
Minimized test:
===============
------- T.java -------
import java.io.*;
import java.util.*;
import java.util.logging.*;
public class T extends StreamHandler {
public T() {
super();
}
public void setOutputStream(OutputStream out) throws SecurityException {
super.setOutputStream(out);
}
public static void main(String[] args) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
T sHandler = new T();
try {
sHandler.setOutputStream(out);
} catch (Exception e) {
System.out.println(e);
}
try {
sHandler.publish(null);
} catch (NullPointerException e) {
e.printStackTrace();
}
try {
sHandler.isLoggable(null);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
}
------- end-of-T.java -------
Minimized test output:
======================
java.lang.NullPointerException
at java.util.logging.Handler.isLoggable(Handler.java:262)
at java.util.logging.StreamHandler.isLoggable(StreamHandler.java:216)
at java.util.logging.StreamHandler.publish(StreamHandler.java:174)
at T.main(T.java:22)
java.lang.NullPointerException
at java.util.logging.Handler.isLoggable(Handler.java:262)
at java.util.logging.StreamHandler.isLoggable(StreamHandler.java:216)
at T.main(T.java:27)
======================================================================