Index: java/net/URLConnection.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/net/URLConnection.java,v retrieving revision 1.21 diff -u -b -B -r1.21 URLConnection.java --- java/net/URLConnection.java 6 Jan 2004 10:07:59 -0000 1.21 +++ java/net/URLConnection.java 25 Jan 2004 13:35:11 -0000 @@ -1,5 +1,5 @@ /* URLConnection.java -- Abstract superclass for reading from URL's - Copyright (C) 1998, 2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1998, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -94,7 +94,7 @@ * to do this is implemented by this class, so just create an empty * instance and store it here. */ - private static FileNameMap fileNameMap = new MimeTypeMapper(); + private static FileNameMap fileNameMap; /** * This is the ContentHandlerFactory set by the caller, if any @@ -888,7 +888,7 @@ */ public static String guessContentTypeFromName(String filename) { - return(fileNameMap.getContentTypeFor(filename.toLowerCase())); + return getFileNameMap().getContentTypeFor(filename.toLowerCase()); } /** @@ -921,8 +921,14 @@ * * @since 1.2 */ - public static FileNameMap getFileNameMap() + public static synchronized FileNameMap getFileNameMap() { + // Delayed initialization. + if (fileNameMap == null) + { + fileNameMap = new MimeTypeMapper(); + } + return fileNameMap; } @@ -947,5 +953,4 @@ fileNameMap = map; } -} // class URLConnection - +}