Fresh install of FC4 with GCJ libgcj-4.0.0 in classpath -- sorry, don't know what version of Classpath that is. If you call the getHeaderFieldKey method with a header index that is out of range, it throws a NoSuchElementException rather than return null. This is a regression against GCJ 3.3.4.
Created attachment 9819 [details] Sorry, an earlier draft got uploaded, this does not compile, see follow-up attachment. Compile and run the main method without any arguments. It creates an URL, makes an URLConnection and requests a header key out of index.
Comment on attachment 9819 [details] Sorry, an earlier draft got uploaded, this does not compile, see follow-up attachment. package com.mkdoc.bug; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.util.NoSuchElementException; public class HttpHeaderFieldKeyTest { /** * A test URL from which to get headers. */ private static final String TEST_URL = "http://test.mksearch.mkdoc.org/"; /** * Index out of range. */ private static final int INDEX = 94860; /** * Run the test, no arguments. */ public static final void main(String[] args) { URL url = null; URLConnection connection = null; try { url = new URL(TEST_URL); connection = url.openConnection(); connection.connect(); try { String header = connection.getHeaderFieldKey(INDEX); if (header == null) { System.out.println("Test passes, method returned null."); } else { System.err.println("Test fails, header at index " + INDEX + " has value '" + header + "'."); } } catch (NoSuchElementException nsee) { System.err.println("Test fails, NoSuchElementException thrown."); } } catch (IOException ioe) { System.err.println("Test did not run, connection error for URL " + TEST_URL); } } }
Comment on attachment 9819 [details] Sorry, an earlier draft got uploaded, this does not compile, see follow-up attachment. >package com.mkdoc.bug; > >import java.io.IOException; > >import java.net.URL; >import java.net.URLConnection; > >import java.util.NoSuchElementException; > >public class HttpHeaderFieldKeyTest { > > /** > * A test URL from which to get headers. > */ > private static final String TEST_URL = "http://test.mksearch.mkdoc.org/"; > > /** > * Index out of range. > */ > private static final int INDEX = 94860; > > /** > * Run the test, no arguments. > */ > public static final void main(String[] args) { > > URL url = null; > > URLConnection connection = null; > > try { > > url = new URL(TEST_URL); > > connection = url.openConnection(); > > connection.connect(); > > try { > > String header = connection.getHeaderFieldKey(INDEX); > > if (header == null) { > > System.out.println("Test passes, method returned null."); > } > else { > > System.err.println("Test fails, header at index " + > INDEX + > " has value '" + > header + > "'."); > } > } > catch (NoSuchElementException nsee) { > > System.err.println("Test fails, NoSuchElementException thrown."); > } > } > catch (IOException ioe) { > > System.err.println("Connection error for URL " + > TEST_URL); > } > finally { > > if (connection != null) { > > connection.disconnect(); > } > } > > } > >} Sorry, an earlier draft got uploaded, this does not compile, see follow-up. package com.mkdoc.bug; import java.io.IOException; import java.net.URL; import java.net.URLConnection; import java.util.NoSuchElementException; public class HttpHeaderFieldKeyTest { /** * A test URL from which to get headers. */ private static final String TEST_URL = "http://test.mksearch.mkdoc.org/"; /** * Index out of range. */ private static final int INDEX = 94860; /** * Run the test, no arguments. */ public static final void main(String[] args) { URL url = null; URLConnection connection = null; try { url = new URL(TEST_URL); connection = url.openConnection(); connection.connect(); try { String header = connection.getHeaderFieldKey(INDEX); if (header == null) { System.out.println("Test passes, method returned null."); } else { System.err.println("Test fails, header at index " + INDEX + " has value '" + header + "'."); } } catch (NoSuchElementException nsee) { System.err.println("Test fails, NoSuchElementException thrown."); } } catch (IOException ioe) { System.err.println("Test did not run, connection error for URL " + TEST_URL); } } }
Created attachment 9820 [details] Simple test case for bug. Compile and run main method without arguments.
Just ran the testcase on: $ gcj --version gcj (GCC) 4.1.0 20050926 (experimental) This is the output obtained: $ ./HttpHeaderFieldKeyTest Test passes, method returned null. $