diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 6cb290b270f4a58382d9774f84abfe134516bd26..22f85229320e0192e2de35a533d8e013c2318cc4 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,12 @@ +2000-02-25 Bryce McKinlay <bryce@albatross.co.nz> + + * java/net/URLConnection.java (initializeDateFormats): New + private method. + (getHeaderFieldDate): Call initializeDateFormats if required. + locale, dateFormat1, dateFormat2, dateFormat3: Don't initialize + these. + Fix for PR libgcj/38. + 2000-02-24 Warren Levy <warrenl@cygnus.com> * java/math/BigInteger.java(ival): Made private. diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index a9b42e916015863efbe7b3b6c93f2f529861319c..60cfd76714f6300720d9d911ae95dfc4bf504e21 100644 --- a/libjava/java/net/URLConnection.java +++ b/libjava/java/net/URLConnection.java @@ -47,13 +47,9 @@ public abstract class URLConnection private static ContentHandlerFactory factory; private static ContentHandler contentHandler; private static Hashtable handlers = new Hashtable(); - private static Locale locale = new Locale("En", "Us", "Unix"); - private static SimpleDateFormat dateFormat1 = - new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", locale); - private static SimpleDateFormat dateFormat2 = - new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", locale); - private static SimpleDateFormat dateFormat3 = - new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale); + private static Locale locale; + private static SimpleDateFormat dateFormat1, dateFormat2, dateFormat3; + private static boolean dateformats_initialized = false; protected URLConnection(URL url) { @@ -128,6 +124,8 @@ public abstract class URLConnection public long getHeaderFieldDate(String name, long val) { + if (! dateformats_initialized) + initializeDateFormats(); String str = getHeaderField(name); if (str != null) { @@ -437,4 +435,20 @@ public abstract class URLConnection handlers.put(contentType, contentType); return null; } + + // We don't put these in a static initializer, because it creates problems + // with initializer co-dependency: SimpleDateFormat's constructors eventually + // depend on URLConnection (via the java.text.*Symbols classes). + private synchronized void initializeDateFormats() + { + if (dateformats_initialized) + return; + locale = new Locale("En", "Us", "Unix"); + dateFormat1 = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss 'GMT'", + locale); + dateFormat2 = new SimpleDateFormat("EEEE, dd-MMM-yy hh:mm:ss 'GMT'", + locale); + dateFormat3 = new SimpleDateFormat("EEE MMM d hh:mm:ss yyyy", locale); + dateformats_initialized = true; + } }