servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject servicemix-specs git commit: [SM-2590]javax.activation.MimetypesFileTypeMap#addMimeTypes() not implemented correctly
Date Wed, 17 Jun 2015 01:20:26 GMT
Repository: servicemix-specs
Updated Branches:
  refs/heads/master 9d965139f -> 8caa0aca9


[SM-2590]javax.activation.MimetypesFileTypeMap#addMimeTypes() not implemented correctly


Project: http://git-wip-us.apache.org/repos/asf/servicemix-specs/repo
Commit: http://git-wip-us.apache.org/repos/asf/servicemix-specs/commit/8caa0aca
Tree: http://git-wip-us.apache.org/repos/asf/servicemix-specs/tree/8caa0aca
Diff: http://git-wip-us.apache.org/repos/asf/servicemix-specs/diff/8caa0aca

Branch: refs/heads/master
Commit: 8caa0aca9e26d8b817b6491eb1f17f85540f03ee
Parents: 9d96513
Author: Freeman Fang <freeman.fang@gmail.com>
Authored: Wed Jun 17 09:20:00 2015 +0800
Committer: Freeman Fang <freeman.fang@gmail.com>
Committed: Wed Jun 17 09:20:00 2015 +0800

----------------------------------------------------------------------
 .../javax/activation/MimetypesFileTypeMap.java  | 25 +++++++++++++++++---
 1 file changed, 22 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/servicemix-specs/blob/8caa0aca/activation-api-1.1/src/main/java/javax/activation/MimetypesFileTypeMap.java
----------------------------------------------------------------------
diff --git a/activation-api-1.1/src/main/java/javax/activation/MimetypesFileTypeMap.java b/activation-api-1.1/src/main/java/javax/activation/MimetypesFileTypeMap.java
index ed78099..bf8836a 100644
--- a/activation-api-1.1/src/main/java/javax/activation/MimetypesFileTypeMap.java
+++ b/activation-api-1.1/src/main/java/javax/activation/MimetypesFileTypeMap.java
@@ -27,6 +27,7 @@ import java.io.InputStreamReader;
 import java.io.FileReader;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
+import java.io.StringReader;
 import java.util.Map;
 import java.util.HashMap;
 import java.util.StringTokenizer;
@@ -122,7 +123,7 @@ public class MimetypesFileTypeMap extends FileTypeMap {
         try {
             String line;
             while ((line = reader.readLine()) != null) {
-                addMimeTypes(line);
+                addMimeTypesOneLine(line);
             }
             reader.close();
         } catch (IOException e) {
@@ -148,11 +149,11 @@ public class MimetypesFileTypeMap extends FileTypeMap {
         BufferedReader reader = new BufferedReader(new InputStreamReader(is));
         String line;
         while ((line = reader.readLine()) != null) {
-            addMimeTypes(line);
+            addMimeTypesOneLine(line);
         }
     }
 
-    public synchronized void addMimeTypes(String mime_types) {
+    private synchronized void addMimeTypesOneLine(String mime_types) {
         int hashPos = mime_types.indexOf('#');
         if (hashPos != -1) {
             mime_types = mime_types.substring(0, hashPos);
@@ -167,6 +168,24 @@ public class MimetypesFileTypeMap extends FileTypeMap {
             types.put(fileType, contentType);
         }
     }
+    
+    public synchronized void addMimeTypes(String mime_types) {
+        BufferedReader reader = new BufferedReader(new StringReader(mime_types));
+        try {
+            String line;
+            while ((line = reader.readLine()) != null) {
+                addMimeTypesOneLine(line);
+            }
+            reader.close();
+        } catch (IOException e) {
+            try {
+                reader.close();
+            } catch (IOException e1) {
+                e1.printStackTrace();
+            }
+        }
+    }
+
 
     public String getContentType(File f) {
         return getContentType(f.getName());


Mime
View raw message