From: Per-Åke Minborg Date: Fri, 28 Oct 2016 18:07:23 +0000 (-0700) Subject: Replace Hashtable X-Git-Tag: 8.0.0.alpha7~13 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3e2ddb469152c430bde5d2c61a9b279a10a8806f;p=vaadin-framework.git Replace Hashtable Change-Id: I80b73b653e97904605dc62484a7448f3bfbf7229 --- diff --git a/server/src/main/java/com/vaadin/util/FileTypeResolver.java b/server/src/main/java/com/vaadin/util/FileTypeResolver.java index 39da3da890..4df2785ce8 100644 --- a/server/src/main/java/com/vaadin/util/FileTypeResolver.java +++ b/server/src/main/java/com/vaadin/util/FileTypeResolver.java @@ -19,9 +19,9 @@ package com.vaadin.util; import java.io.File; import java.io.Serializable; import java.util.Collections; -import java.util.Hashtable; import java.util.Map; import java.util.StringTokenizer; +import java.util.concurrent.ConcurrentHashMap; import com.vaadin.server.Resource; import com.vaadin.server.ThemeResource; @@ -210,12 +210,12 @@ public class FileTypeResolver implements Serializable { /** * File extension to MIME type mapping. All extensions are in lower case. */ - static private Hashtable extToMIMEMap = new Hashtable<>(); + private static final Map EXT_TO_MIME_MAP = new ConcurrentHashMap<>(); /** * MIME type to Icon mapping. */ - static private Hashtable MIMEToIconMap = new Hashtable<>(); + private static final Map MIME_TO_ICON_MAP = new ConcurrentHashMap<>(); static { @@ -270,7 +270,7 @@ public class FileTypeResolver implements Serializable { } // Return type from extension map, if found - final String type = extToMIMEMap.get(ext.toLowerCase()); + final String type = EXT_TO_MIME_MAP.get(ext.toLowerCase()); if (type != null) { return type; } @@ -294,7 +294,7 @@ public class FileTypeResolver implements Serializable { } private static Resource getIconByMimeType(String mimeType) { - final Resource icon = MIMEToIconMap.get(mimeType); + final Resource icon = MIME_TO_ICON_MAP.get(mimeType); if (icon != null) { return icon; } @@ -358,7 +358,7 @@ public class FileTypeResolver implements Serializable { * the new mime-type for extension. */ public static void addExtension(String extension, String MIMEType) { - extToMIMEMap.put(extension.toLowerCase(), MIMEType); + EXT_TO_MIME_MAP.put(extension.toLowerCase(), MIMEType); } /** @@ -371,7 +371,7 @@ public class FileTypeResolver implements Serializable { * the new icon to be associated with MIMEType. */ public static void addIcon(String MIMEType, Resource icon) { - MIMEToIconMap.put(MIMEType, icon); + MIME_TO_ICON_MAP.put(MIMEType, icon); } /** @@ -381,7 +381,7 @@ public class FileTypeResolver implements Serializable { * mime-type mapping */ public static Map getExtensionToMIMETypeMapping() { - return Collections.unmodifiableMap(extToMIMEMap); + return Collections.unmodifiableMap(EXT_TO_MIME_MAP); } /** @@ -390,7 +390,7 @@ public class FileTypeResolver implements Serializable { * @return unmodifiable map containing the current mime-type to icon mapping */ public static Map getMIMETypeToIconMapping() { - return Collections.unmodifiableMap(MIMEToIconMap); + return Collections.unmodifiableMap(MIME_TO_ICON_MAP); } private FileTypeResolver() {