public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug java/21074] New: Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
@ 2005-04-17 18:48 kreijack at inwind dot it
  2005-04-17 18:52 ` [Bug libgcj/21074] " pinskia at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: kreijack at inwind dot it @ 2005-04-17 18:48 UTC (permalink / raw)
  To: java-prs

Hi, 
 
I found a little bug in the implementention of the method  
getHeaderFieldKey( int index ) in the file  
java/net/protocol/http/HTTPURLConnection.java. 
 
This method doesn't check if the parameter 'index' if out of range, so if it  
is called with a index value too high a java.util.NoSuchElementException is  
raised. 
Instead the java doc  
( http://java.sun.com/j2se/1.4.2/docs/api/java/net/HttpURLConnection.html#getHeaderFieldKey(int) )  
report that this method should return 'the value of the nth header field, or  
null if the value does not exist.' 
 
I suggest this patch to correct this beaviour; the patch implement the same  
control performed by the method getHeaderField( ). 
 
--- old/libjava/gnu/java/net/protocol/http/HTTPURLConnection.java       Sun  
Apr 17 11:10:59 2005 
+++ new/libjava/gnu/java/net/protocol/http/HTTPURLConnection.java       Sun  
Apr 17 11:13:53 2005 
@@ -543,6 +543,10 @@ 
     int count = 1; 
     do 
       { 
+        if (!i.hasNext()) 
+          { 
+            return null; 
+          } 
         entry = (Map.Entry) i.next(); 
         count++; 
       } 
 
 
Below are the test case used to highligh the problem, comparing the beaviour  
of the sun's java and the gnu one. The last case is a case with the patch 
applied 
 
[ghigo@therra tmp]$ cat testbed.java 
import java.net.*; 
 
public class testbed { 
 
        static public void main( String args[] ) throws Exception { 
 
                URL u=new URL(args[0]); 
                HttpURLConnection con = (HttpURLConnection)u.openConnection(); 
 
                int     n=1; 
                while(true){ 
                        String headerKey = con.getHeaderFieldKey(n); 
                        if(headerKey==null ){ 
                                System.out.print("con.getHeaderFieldKey( ) has  
returned null\n"); 
                                break; 
                        } 
                        System.out.print("headerKey: "+headerKey+"\n"); 
                        String headerVal = con.getHeaderField(n); 
                        System.out.print("headerVal: "+headerVal+"\n"); 
 
                        n++; 
                } 
        } 
 
} 
 
 
[ghigo@therra tmp]$ java -version    # Fedora core 4 test 2 
java version "1.4.2" 
gcj (GCC) 4.0.0 20050405 (Red Hat 4.0.0-0.40) 
Copyright (C) 2005 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 
[ghigo@therra tmp]$ java -cp . testbed http://www.google.com 
headerKey: Cache-Control 
headerVal: private 
headerKey: Content-Type 
headerVal: text/html 
headerKey: Set-Cookie 
headerVal:  
PREF=ID=158312593220e9b1:LD=it:TM=1113727883:LM=1113727883:S=Y7zUs9KFT_BVs6d7;  
expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.it 
headerKey: Server 
headerVal: GWS/2.1 
headerKey: Transfer-Encoding 
headerVal: chunked 
headerKey: Date 
headerVal: Sun, 17 Apr 2005 08:51:23 GMT 
Exception in thread "main" java.util.NoSuchElementException 
   at java.util.LinkedHashMap$1.next() (/usr/lib/libgcj.so.6.0.0) 
   at gnu.java.net.protocol.http.HTTPURLConnection.getHeaderFieldKey(int)  
(/usr/lib/libgcj.so.6.0.0) 
   at testbed.main(java.lang.String[]) (Unknown Source) 
   at gnu.java.lang.MainThread.call_main() (/usr/lib/libgcj.so.6.0.0) 
   at gnu.java.lang.MainThread.run() (/usr/lib/libgcj.so.6.0.0) 
 
[ghigo@therra tmp]$ /usr/local/java-1.5/jdk1.5.0_01/bin/java -version  
java version "1.5.0_01" 
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08) 
Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing) 
[ghigo@therra tmp]$ /usr/local/java-1.5/jdk1.5.0_01/bin/java -cp . testbed  
http://www.google.com 
headerKey: Cache-Control 
headerVal: private 
headerKey: Content-Type 
headerVal: text/html 
headerKey: Set-Cookie 
headerVal:  
PREF=ID=81a840411c05e572:LD=it:TM=1113727895:LM=1113727895:S=B5ZxkSzn6RkPyhGV;  
expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.it 
headerKey: Server 
headerVal: GWS/2.1 
headerKey: Transfer-Encoding 
headerVal: chunked 
headerKey: Date 
headerVal: Sun, 17 Apr 2005 08:51:35 GMT 
con.getHeaderFieldKey( ) has returned null 
 
The last example was executed with the patch applied to the java library 
 
[ghigo@therra tmp]$ /opt/gcc-4.0.0-20050410/bin/gcj-400 --version 
gcj-400 (GCC) 4.0.0 20050410 (prerelease) 
Copyright (C) 2005 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
[ghigo@therra tmp]$ CLASSPATH=.:/opt/gcc-4.0.0-20050410/lib \ 
/opt/gcc-4.0.0-20050410/bin/gij-400 testbed http://www.google.com  
http://www.google.com 
headerKey: Cache-Control 
headerVal: private 
headerKey: Content-Type 
headerVal: text/html 
headerKey: Set-Cookie 
headerVal: 
PREF=ID=bb14539184e1692b:LD=it:TM=1113763098:LM=1113763098:S=DpuOWd-IfDkN2-tO; 
expires=Sun, 17-Jan-2038 19:14:07 GMT; path=/; domain=.google.it 
headerKey: Server 
headerVal: GWS/2.1 
headerKey: Transfer-Encoding 
headerVal: chunked 
headerKey: Date 
headerVal: Sun, 17 Apr 2005 18:38:18 GMT 
con.getHeaderFieldKey( ) has returned null 
 
 
Ciao 
Goffredo

-- 
           Summary: Trivial bug in the method  getHeaderFieldKey() in the
                    file java/net/protocol/http/HTTPURLConnection.java
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: java
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kreijack at inwind dot it
                CC: gcc-bugs at gcc dot gnu dot org,java-prs at gcc dot gnu
                    dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libgcj/21074] Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
  2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
@ 2005-04-17 18:52 ` pinskia at gcc dot gnu dot org
  2005-06-15 20:08 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-17 18:52 UTC (permalink / raw)
  To: java-prs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|java                        |libgcj


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libgcj/21074] Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
  2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
  2005-04-17 18:52 ` [Bug libgcj/21074] " pinskia at gcc dot gnu dot org
@ 2005-06-15 20:08 ` cvs-commit at gcc dot gnu dot org
  2005-06-15 20:10 ` tromey at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-06-15 20:08 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-06-15 20:08 -------
Subject: Bug 21074

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tromey@gcc.gnu.org	2005-06-15 20:08:28

Modified files:
	libjava        : ChangeLog 
	libjava/gnu/java/net/protocol/http: HTTPURLConnection.java 

Log message:
	2005-06-15  Goffredo Baroncelli  <kreijack@inwind.it>
	
	PR libgcj/21074:
	* gnu/java/net/protocol/http/HTTPURLConnection.java
	(getHeaderFieldKey): Check index.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&r1=1.3667&r2=1.3668
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/gnu/java/net/protocol/http/HTTPURLConnection.java.diff?cvsroot=gcc&r1=1.3&r2=1.4



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libgcj/21074] Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
  2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
  2005-04-17 18:52 ` [Bug libgcj/21074] " pinskia at gcc dot gnu dot org
  2005-06-15 20:08 ` cvs-commit at gcc dot gnu dot org
@ 2005-06-15 20:10 ` tromey at gcc dot gnu dot org
  2005-08-22 18:05 ` tromey at gcc dot gnu dot org
  2005-08-22 18:06 ` cvs-commit at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-06-15 20:10 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-06-15 20:10 -------
I checked this in on the trunk.
Once the branch status changes, I will check this in to 4.0 and close the PR.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |tromey at gcc dot gnu dot
                   |dot org                     |org
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2005-06-15 20:10:03
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libgcj/21074] Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
  2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
                   ` (2 preceding siblings ...)
  2005-06-15 20:10 ` tromey at gcc dot gnu dot org
@ 2005-08-22 18:05 ` tromey at gcc dot gnu dot org
  2005-08-22 18:06 ` cvs-commit at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: tromey at gcc dot gnu dot org @ 2005-08-22 18:05 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From tromey at gcc dot gnu dot org  2005-08-22 18:05 -------
Committed to 4.0 branch.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.2


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libgcj/21074] Trivial bug in the method  getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java
  2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
                   ` (3 preceding siblings ...)
  2005-08-22 18:05 ` tromey at gcc dot gnu dot org
@ 2005-08-22 18:06 ` cvs-commit at gcc dot gnu dot org
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-08-22 18:06 UTC (permalink / raw)
  To: java-prs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-08-22 18:06 -------
Subject: Bug 21074

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tromey@gcc.gnu.org	2005-08-22 18:06:36

Modified files:
	libjava        : ChangeLog 
	libjava/gnu/java/net/protocol/http: HTTPURLConnection.java 

Log message:
	2005-06-15  Goffredo Baroncelli  <kreijack@inwind.it>
	
	PR libgcj/21074:
	* gnu/java/net/protocol/http/HTTPURLConnection.java
	(getHeaderFieldKey): Check index.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.3391.2.92&r2=1.3391.2.93
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/libjava/gnu/java/net/protocol/http/HTTPURLConnection.java.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.1&r2=1.1.20.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21074


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-08-22 18:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-17 18:48 [Bug java/21074] New: Trivial bug in the method getHeaderFieldKey() in the file java/net/protocol/http/HTTPURLConnection.java kreijack at inwind dot it
2005-04-17 18:52 ` [Bug libgcj/21074] " pinskia at gcc dot gnu dot org
2005-06-15 20:08 ` cvs-commit at gcc dot gnu dot org
2005-06-15 20:10 ` tromey at gcc dot gnu dot org
2005-08-22 18:05 ` tromey at gcc dot gnu dot org
2005-08-22 18:06 ` cvs-commit at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).