-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
hopper
-
sparc
-
solaris_2.6, solaris_8
-
Verified
If the RemoteServer.setLog method is invoked with the argument null and it has either never been invoked before or the previous invocation was also with the argument null, then a NullPointerException is thrown. (If the previous invocation was with a non-null argument, then a null invocation will succeed as documented-- this is the case that the current functional test covers.)
The problem is a simply lack of null check in the sun.rmi.runtime.Log.LoggerLog implementation; see the Suggested Fix.
Following is from external user's description:
>> A DESCRIPTION OF THE PROBLEM :
>> The following code worked on jdk1.3.1 but fails with a null
>> pointer exception on jdk1.4.0.
>>
>> public class SunBug {
>>
>> public static void main(String[] args) {
>> java.rmi.server.RemoteServer.setLog(null);
>> }
>>
>> }
>>
>> Javadoc states that null is a valid parameter to setLog().
>>
>> setLog
>>
>> public static void setLog(OutputStream out)
>>
>> Log RMI calls to the output stream out. If out is null,
>> call logging is turned off.
>>
>> Parameters:
>> out - the output stream to which RMI calls should be
>> loggedSince:
>> JDK1.1
>>
>>
>> REGRESSION. Last worked in version 1.3.1
>>
>> STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
>> 1. Enter and compile the SunBug.java code listed in description.
>> 2. Run SunBug.
>>
>> EXPECTED VERSUS ACTUAL BEHAVIOR :
>> On 1.3.1:
>> <no output>
>>
>> On 1.4.0:
>> Exception in thread "main" java.lang.NullPointerException
>> at
>> java.util.logging.Logger.removeHandler(Logger.java:1150)
>> at
>> sun.rmi.runtime.Log$LoggerLog.setOutputStream(Log.java:242)
>> at
>> java.rmi.server.RemoteServer.setLog(RemoteServer.java:72)
>> at SunBug.main(SunBug.java:4)
>>
>>
>> ERROR MESSAGES/STACK TRACES THAT OCCUR :
>> Exception in thread "main" java.lang.NullPointerException
>> at java.util.logging.Logger.removeHandler(Logger.java:1150)
>> at sun.rmi.runtime.Log$LoggerLog.setOutputStream(Log.java:242)
>> at java.rmi.server.RemoteServer.setLog(RemoteServer.java:72)
>> at SunBug.main(SunBug.java:4)
>>
>>
>> This bug can be reproduced always.
>>
>> ---------- BEGIN SOURCE ----------
>> public class SunBug {
>>
>> public static void main(String[] args) {
>> java.rmi.server.RemoteServer.setLog(null);
>> }
>>
>> }
>>
>> ---------- END SOURCE ----------
The problem is a simply lack of null check in the sun.rmi.runtime.Log.LoggerLog implementation; see the Suggested Fix.
Following is from external user's description:
>> A DESCRIPTION OF THE PROBLEM :
>> The following code worked on jdk1.3.1 but fails with a null
>> pointer exception on jdk1.4.0.
>>
>> public class SunBug {
>>
>> public static void main(String[] args) {
>> java.rmi.server.RemoteServer.setLog(null);
>> }
>>
>> }
>>
>> Javadoc states that null is a valid parameter to setLog().
>>
>> setLog
>>
>> public static void setLog(OutputStream out)
>>
>> Log RMI calls to the output stream out. If out is null,
>> call logging is turned off.
>>
>> Parameters:
>> out - the output stream to which RMI calls should be
>> loggedSince:
>> JDK1.1
>>
>>
>> REGRESSION. Last worked in version 1.3.1
>>
>> STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
>> 1. Enter and compile the SunBug.java code listed in description.
>> 2. Run SunBug.
>>
>> EXPECTED VERSUS ACTUAL BEHAVIOR :
>> On 1.3.1:
>> <no output>
>>
>> On 1.4.0:
>> Exception in thread "main" java.lang.NullPointerException
>> at
>> java.util.logging.Logger.removeHandler(Logger.java:1150)
>> at
>> sun.rmi.runtime.Log$LoggerLog.setOutputStream(Log.java:242)
>> at
>> java.rmi.server.RemoteServer.setLog(RemoteServer.java:72)
>> at SunBug.main(SunBug.java:4)
>>
>>
>> ERROR MESSAGES/STACK TRACES THAT OCCUR :
>> Exception in thread "main" java.lang.NullPointerException
>> at java.util.logging.Logger.removeHandler(Logger.java:1150)
>> at sun.rmi.runtime.Log$LoggerLog.setOutputStream(Log.java:242)
>> at java.rmi.server.RemoteServer.setLog(RemoteServer.java:72)
>> at SunBug.main(SunBug.java:4)
>>
>>
>> This bug can be reproduced always.
>>
>> ---------- BEGIN SOURCE ----------
>> public class SunBug {
>>
>> public static void main(String[] args) {
>> java.rmi.server.RemoteServer.setLog(null);
>> }
>>
>> }
>>
>> ---------- END SOURCE ----------
- duplicates
-
JDK-4739072 RemoteServer.setLog(null) throws NPE unexpectedly in 1.4
-
- Closed
-