PQ74568: JAVA.NET.URL.GETPATH() RETURNS NULL AND CAUSES NULLPOINTEREXCEPTION DUE TO A JDK BUG. | |||||||||||||||||||||||||||||||||
![]() |
|||||||||||||||||||||||||||||||||
APAR status Closed as program error. Error description Problem Description: A call to java.net.URL.getPath() causes a NullPointerException in application that makes the call. The customer found that the IBM jdks were working properly and that the problem only exhibited itself on Solaris jdk 1.3.1_05 and jdk 1.3.1_07. . Problem Summary: The customer has the following block of code that works ok on Windows but fails to work on Solaris (WAS 4.0.4 using jdk 1.3.1_05). This is the test method that fails to run on Solaris. public class UrlTest { public static void main (String args) { try{ URL url = new URL("file:/home/sb/config.xml"); . ByteArrayOutputStream bOutputStream=new ByteArrayOutputStream(); ObjectOutputStream objOutputStream = new ObjectOutputStream(bOutputStream); objOutputStream.writeObject(url); ByteArrayInputStream bInputStream = new ByteArrayInputStream(bOutputStream.toByteArray()); ObjectInputStream objInputStream = new ObjectInputStream(bInputStream); . URL url2 = (URL)objInputStream.readObject(); . System.out.println("External form = " + url2.toExternalForm() System.out.println("Path = " + url2.getPath()); }catch(Exception ex){ ex.printStackTrace(); } } } . If you run it on SUN JDK 1.3.1_5, the output will be "Path = null". But, if you run it on IBM jdk for Win2k, the output will be like, "Path = /home/sb/config.xml" .Local fix The java.net.URL class can be patched to fix the error in the getObject call that causes the problem. . This is a bug in Sun's Solaris JDK. It has been fixed in IBM's JDKs (CMVC SOV defect 33882) and in Sun's 1.4.0. The fix is simple - a programming error was made in the readObject method of java.net.URL. URL has class variables called path and query which should be set to the correct values by readObject, but path and query are declared locally as Strings in readObject, so changes to them are lost when the method exits, and the class variables remain null. . Tweaking the URL class to properly handle these variables could be done as an interim solution. . This is SunBug 4337842. . This is fixed in any IBM jdk that includes the defect fix for defect SOV 33882. 33882 was committed on 05/07/2001. . This is fixed in the Solaris jdk beginning with jdk 1.3.1_09, which is scheduled for availability by 8/1/2003. A jdk with the bugfix for this problem for Solaris is available from WAS L2 support. The jdk image for the 545235-jdk-image-sparc.tar.gz has this fix.Problem summary **************************************************************** * USERS AFFECTED: All WebSphere Application Server users of * * Solaris jdk 1.3.1_05 and jdk 1.3.1_07. * **************************************************************** * PROBLEM DESCRIPTION: java.net.url.getPath() returns null * * and causes NullPointerException due * * to a JDK bug. * **************************************************************** * RECOMMENDATION: * **************************************************************** A call to java.net.URL.getPath() causes a NullPointerException in the application that makes the call. This happens only on Solaris jdk 1.3.1_05 and jdk 1.3.1_07.Problem conclusion This is a JDK SOV defect 33882 and is fixed in the Solaris jdk beginning with jdk 1.3.1_09.Temporary fix Comments
APAR is sysrouted FROM one or more of the following: APAR is sysrouted TO one or more of the following: Modules/Macros
|
Document Information |
Product categories: Software > Application Servers >
Distributed Application & Web Servers > WebSphere Application
Server > General
Operating system(s):
Software version: 400
Software edition:
Reference #: PQ74568
IBM Group: Software Group
Modified date: May 27, 2003
(C) Copyright IBM Corporation 2000, 2006. All Rights Reserved.