< prev index next >
src/share/classes/java/net/URLConnection.java
Print this page
*** 283,298 ****
private MessageHeader requests;
/**
* @since JDK1.1
*/
! private static FileNameMap fileNameMap;
!
! /**
! * @since 1.2.2
! */
! private static boolean fileNameMapLoaded = false;
/**
* Loads filename map (a mimetable) from a data file. It will
* first try to load the user-specific table, defined
* by "content.types.user.table" property. If that fails,
--- 283,293 ----
private MessageHeader requests;
/**
* @since JDK1.1
*/
! private static volatile FileNameMap fileNameMap;
/**
* Loads filename map (a mimetable) from a data file. It will
* first try to load the user-specific table, defined
* by "content.types.user.table" property. If that fails,
*** 300,323 ****
*
* @return the FileNameMap
* @since 1.2
* @see #setFileNameMap(java.net.FileNameMap)
*/
! public static synchronized FileNameMap getFileNameMap() {
! if ((fileNameMap == null) && !fileNameMapLoaded) {
! fileNameMap = sun.net.www.MimeTable.loadTable();
! fileNameMapLoaded = true;
! }
- return new FileNameMap() {
- private FileNameMap map = fileNameMap;
public String getContentTypeFor(String fileName) {
! return map.getContentTypeFor(fileName);
}
};
}
/**
* Sets the FileNameMap.
* <p>
* If there is a security manager, this method first calls
* the security manager's {@code checkSetFactory} method
--- 295,321 ----
*
* @return the FileNameMap
* @since 1.2
* @see #setFileNameMap(java.net.FileNameMap)
*/
! public static FileNameMap getFileNameMap() {
! FileNameMap map = fileNameMap;
!
! if (map == null) {
! fileNameMap = map = new FileNameMap() {
! private FileNameMap internalMap =
! sun.net.www.MimeTable.loadTable();
public String getContentTypeFor(String fileName) {
! return internalMap.getContentTypeFor(fileName);
}
};
}
+ return map;
+ }
+
/**
* Sets the FileNameMap.
* <p>
* If there is a security manager, this method first calls
* the security manager's {@code checkSetFactory} method
< prev index next >