diff options
author | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-02-25 22:38:33 +0000 |
---|---|---|
committer | bryce <bryce@138bc75d-0d04-0410-961f-82ee72b054a4> | 2000-02-25 22:38:33 +0000 |
commit | 2eb7a7795d5911abea9c1f90078c8a4fba336dd2 (patch) | |
tree | 251f10be1ba038997fcdd6f8b2fa78080ac48f20 /libjava/java | |
parent | f10edf5aa26c38647581b91710a53585eaba3c0f (diff) | |
download | ppe42-gcc-2eb7a7795d5911abea9c1f90078c8a4fba336dd2.tar.gz ppe42-gcc-2eb7a7795d5911abea9c1f90078c8a4fba336dd2.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@32153 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java')
-rw-r--r-- | libjava/java/net/URLConnection.java | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index a9b42e91601..60cfd76714f 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; + } } |