-
Bug
-
Resolution: Fixed
-
P2
-
5.0
-
b46
-
x86
-
solaris_9, windows_2000
Filed By : SPB JCK team (###@###.###)
JDK : java full version "1.5.0-beta2-b45"
JCK : 1.5
Platform[s] : Solaris X86, Windows
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : Following tests are affected during test run:
> api/java_net/URLConnection/descriptions.html#getDate
> api/java_net/URLConnection/descriptions.html#doOutput
> api/java_net/URL/descriptions.html#getContent
> api/java_net/URLConnection/descriptions.html#UseCaches
>
Problem description:
====================
Method of class sun.net.www.protocol.http.HttpURLConnection
public synchronized InputStream getInputStream()
periodically throws unexpected NullPointerException.
Minimized test:
===============
--- test1.java ---
import java.net.*;
import java.io.*;
public class test1 {
public static void main (String args[]){
for (int i = 0; i <20; i++) {
System.out.print(i + ": ");
test1 t = new test1();
}
}
String http_url = "http://javaweb/jck/index.html";
URLConnection conn;
public test1() {
URL url = null;
UCConfig conf = null;
Object is = null;
InputStream is1 = null;
int i, count = 0;
try {
conf = new UCConfig(http_url, false);
is1 = conf.getInputStream();
} catch(RuntimeException e) {
System.out.println("Can not setup test:" + e);
}
try {
url = new URL(http_url);
conn = url.openConnection();
Class[] classes = {};
is = conn.getContent(classes);
} catch(IOException e) {
System.out.println("Unexpected exception:" + e);
} finally {
close(is); conf.close();
}
if (is == null)
System.out.println("OKAY");
else {
System.out.println("method getContent(Class[]) works unexpectedly with an empty array. It returns an object of " + is.getClass() + " type");
}
}
public void close(Object obj) {
try {
if (obj != null) {
if (obj instanceof InputStream) {
((InputStream) obj).close();
} else if (obj instanceof Reader) {
((Reader) obj).close();
}
}
} catch (IOException ioe) {
System.out.println("Cannot close:" + obj + " :" + ioe);
}
}
}
class UCConfig {
URL url = null;
Socket soc = null;
Socket dsoc = null;
BufferedReader rdr = null;
BufferedWriter wrt = null;
InputStream is = null;
OutputStream os = null;
PrintStream pos = null;
public UCConfig(String surl, boolean closeStreams) {
try {
url = new URL(surl);
} catch (Exception e) {
throw new RuntimeException("Failed to setup - invalid URL:" + url);
}
parseHttpHeaders();
if (closeStreams) close();
}
private void parseHttpHeaders() {
SecurityManager sec = System.getSecurityManager();
String host = null;
String file = null;
String req = null;
String head_line = null;
int port = 80;
host = url.getHost();
file = url.getFile().length() < 1 ? "/" : url.getFile();
port = url.getPort()> 0 ? url.getPort() : 80;
req = "GET " + ( file + " HTTP/1.0" );
if (host == null) {
throw new RuntimeException("Failed to setup - invalid host");
}
try {
soc = new Socket(host, port);
is = soc.getInputStream();
os = soc.getOutputStream();
} catch (Exception e) {
throw new RuntimeException("Can not connect to host:" + host + ":" + e);
}
if (is == null) {
throw new RuntimeException("Can not get InputStream");
}
if (os == null) {
throw new RuntimeException("Can not get OutputStream");
}
try {
String encoding = "US-ASCII";
rdr = new BufferedReader( new InputStreamReader(is, encoding) );
wrt = new BufferedWriter( new OutputStreamWriter(os, encoding) );
} catch (java.io.UnsupportedEncodingException e2) {
// should never arise
throw new RuntimeException("Unknown ascii encoding : " + e2);
}
try {
wrt.write(req, 0, req.length());
wrt.write("\r\n");
wrt.write("\r\n");
wrt.flush();
} catch (Exception e) {
throw new RuntimeException("Can not write request");
}
/*
* Read in head lines....
*/
try {
rdr.readLine();
} catch (Exception e) {
throw new RuntimeException("Can not read from server..." + e);
}
}
public InputStream getInputStream() {
return is;
}
public void close() {
try {
if ( is != null )
is.close();
if ( os != null )
os.close();
if ( soc != null )
soc.close();
if ( dsoc != null )
dsoc.close();
} catch (IOException e) {
// ignore
}
}
}
--- end ---
Minimized test output:
======================
% uname -a
SunOS jctjck16 5.9 Generic_112234-05 i86pc i386 i86pc
% /java/re/jdk/1.5.0/promoted/beta2/b45/binaries/solaris-i586/bin/java test1
0: OKAY
1: OKAY
2: OKAY
3: OKAY
4: OKAY
5: OKAY
6: OKAY
7: OKAY
8: OKAY
9: Exception in thread "main" java.lang.NullPointerException
at sun.net.www.http.HttpClient.getProxyPortUsed(HttpClient.java:867)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:356)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:820)
at java.net.URLConnection.getContent(URLConnection.java:708)
at test1.<init>(test1.java:32)
at test1.main(test1.java:8)
Additional comments:
======================
This bug have been introduced in JDK 1.5.0-beta2-b42 promotion.
Specific Machine Info:
=====================
Windows_NT JCTJCK23 5 02 586
SunOS jctjck16 5.9 Generic_112234-05 i86pc i386 i86pc
-------------------
###@###.### 2004-05-07
Same problem reported by a CAP member:
J2SE Version (please include all output from java -version flag):
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b44)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b44, mixed mode, sharing)
Does this problem occur on J2SE 1.3.x or 1.4.x? Yes / No (pick one)
No, it occur on 1.5.
Operating System Configuration Information (be specific):
Microsoft Windows 2000 Server
Version 5.0.2195 Service Pack 4 Build 2195
Hardware Configuration Information (be specific):
Pentium 4, x86 Family 15 Model 1 Stepping 2 GenuineIntel ~1694 MHz
1GB Memory
Bug Description:
We get the following exception with v 1.5.0 beta 2 build 44:
java.lang.NullPointerException
at sun.net.www.http.HttpClient.getProxyPortUsed(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
after we have called the method:
URLConnection urlConnection;
urlConnection = url.openConnection();
urlConnection.setUseCaches(true);
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
Steps to Reproduce (be specific):
URLConnection urlConnection;
urlConnection = url.openConnection();
urlConnection.setUseCaches(true);
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
###@###.### 2004-09-27
JDK : java full version "1.5.0-beta2-b45"
JCK : 1.5
Platform[s] : Solaris X86, Windows
switch/Mode :
JCK test owner : http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
Failing Test [s] : Following tests are affected during test run:
> api/java_net/URLConnection/descriptions.html#getDate
> api/java_net/URLConnection/descriptions.html#doOutput
> api/java_net/URL/descriptions.html#getContent
> api/java_net/URLConnection/descriptions.html#UseCaches
>
Problem description:
====================
Method of class sun.net.www.protocol.http.HttpURLConnection
public synchronized InputStream getInputStream()
periodically throws unexpected NullPointerException.
Minimized test:
===============
--- test1.java ---
import java.net.*;
import java.io.*;
public class test1 {
public static void main (String args[]){
for (int i = 0; i <20; i++) {
System.out.print(i + ": ");
test1 t = new test1();
}
}
String http_url = "http://javaweb/jck/index.html";
URLConnection conn;
public test1() {
URL url = null;
UCConfig conf = null;
Object is = null;
InputStream is1 = null;
int i, count = 0;
try {
conf = new UCConfig(http_url, false);
is1 = conf.getInputStream();
} catch(RuntimeException e) {
System.out.println("Can not setup test:" + e);
}
try {
url = new URL(http_url);
conn = url.openConnection();
Class[] classes = {};
is = conn.getContent(classes);
} catch(IOException e) {
System.out.println("Unexpected exception:" + e);
} finally {
close(is); conf.close();
}
if (is == null)
System.out.println("OKAY");
else {
System.out.println("method getContent(Class[]) works unexpectedly with an empty array. It returns an object of " + is.getClass() + " type");
}
}
public void close(Object obj) {
try {
if (obj != null) {
if (obj instanceof InputStream) {
((InputStream) obj).close();
} else if (obj instanceof Reader) {
((Reader) obj).close();
}
}
} catch (IOException ioe) {
System.out.println("Cannot close:" + obj + " :" + ioe);
}
}
}
class UCConfig {
URL url = null;
Socket soc = null;
Socket dsoc = null;
BufferedReader rdr = null;
BufferedWriter wrt = null;
InputStream is = null;
OutputStream os = null;
PrintStream pos = null;
public UCConfig(String surl, boolean closeStreams) {
try {
url = new URL(surl);
} catch (Exception e) {
throw new RuntimeException("Failed to setup - invalid URL:" + url);
}
parseHttpHeaders();
if (closeStreams) close();
}
private void parseHttpHeaders() {
SecurityManager sec = System.getSecurityManager();
String host = null;
String file = null;
String req = null;
String head_line = null;
int port = 80;
host = url.getHost();
file = url.getFile().length() < 1 ? "/" : url.getFile();
port = url.getPort()> 0 ? url.getPort() : 80;
req = "GET " + ( file + " HTTP/1.0" );
if (host == null) {
throw new RuntimeException("Failed to setup - invalid host");
}
try {
soc = new Socket(host, port);
is = soc.getInputStream();
os = soc.getOutputStream();
} catch (Exception e) {
throw new RuntimeException("Can not connect to host:" + host + ":" + e);
}
if (is == null) {
throw new RuntimeException("Can not get InputStream");
}
if (os == null) {
throw new RuntimeException("Can not get OutputStream");
}
try {
String encoding = "US-ASCII";
rdr = new BufferedReader( new InputStreamReader(is, encoding) );
wrt = new BufferedWriter( new OutputStreamWriter(os, encoding) );
} catch (java.io.UnsupportedEncodingException e2) {
// should never arise
throw new RuntimeException("Unknown ascii encoding : " + e2);
}
try {
wrt.write(req, 0, req.length());
wrt.write("\r\n");
wrt.write("\r\n");
wrt.flush();
} catch (Exception e) {
throw new RuntimeException("Can not write request");
}
/*
* Read in head lines....
*/
try {
rdr.readLine();
} catch (Exception e) {
throw new RuntimeException("Can not read from server..." + e);
}
}
public InputStream getInputStream() {
return is;
}
public void close() {
try {
if ( is != null )
is.close();
if ( os != null )
os.close();
if ( soc != null )
soc.close();
if ( dsoc != null )
dsoc.close();
} catch (IOException e) {
// ignore
}
}
}
--- end ---
Minimized test output:
======================
% uname -a
SunOS jctjck16 5.9 Generic_112234-05 i86pc i386 i86pc
% /java/re/jdk/1.5.0/promoted/beta2/b45/binaries/solaris-i586/bin/java test1
0: OKAY
1: OKAY
2: OKAY
3: OKAY
4: OKAY
5: OKAY
6: OKAY
7: OKAY
8: OKAY
9: Exception in thread "main" java.lang.NullPointerException
at sun.net.www.http.HttpClient.getProxyPortUsed(HttpClient.java:867)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(HttpURLConnection.java:356)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:820)
at java.net.URLConnection.getContent(URLConnection.java:708)
at test1.<init>(test1.java:32)
at test1.main(test1.java:8)
Additional comments:
======================
This bug have been introduced in JDK 1.5.0-beta2-b42 promotion.
Specific Machine Info:
=====================
Windows_NT JCTJCK23 5 02 586
SunOS jctjck16 5.9 Generic_112234-05 i86pc i386 i86pc
-------------------
###@###.### 2004-05-07
Same problem reported by a CAP member:
J2SE Version (please include all output from java -version flag):
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b44)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b44, mixed mode, sharing)
Does this problem occur on J2SE 1.3.x or 1.4.x? Yes / No (pick one)
No, it occur on 1.5.
Operating System Configuration Information (be specific):
Microsoft Windows 2000 Server
Version 5.0.2195 Service Pack 4 Build 2195
Hardware Configuration Information (be specific):
Pentium 4, x86 Family 15 Model 1 Stepping 2 GenuineIntel ~1694 MHz
1GB Memory
Bug Description:
We get the following exception with v 1.5.0 beta 2 build 44:
java.lang.NullPointerException
at sun.net.www.http.HttpClient.getProxyPortUsed(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.writeRequests(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
after we have called the method:
URLConnection urlConnection;
urlConnection = url.openConnection();
urlConnection.setUseCaches(true);
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
Steps to Reproduce (be specific):
URLConnection urlConnection;
urlConnection = url.openConnection();
urlConnection.setUseCaches(true);
urlConnection.setDoInput(true);
urlConnection.connect();
InputStream in = urlConnection.getInputStream();
###@###.### 2004-09-27