From a9653e2f49e96374cc0ae5188c7b27a47d03f229 Mon Sep 17 00:00:00 2001 From: Jan Bartel Date: Wed, 10 Aug 2016 12:07:29 +1000 Subject: [PATCH] Issue #797 Use MimeTypes.class.getClassLoader to load properties. --- .../org/eclipse/jetty/http/MimeTypes.java | 103 ++++++++++++------ 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java index c465b6a0e78..04d8cebe6f4 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/MimeTypes.java @@ -203,50 +203,83 @@ public class MimeTypes } } - String resourceName = "org/eclipse/jetty/http/mime"; - - try + String resourceName = "org/eclipse/jetty/http/mime.properties"; + try (InputStream stream = MimeTypes.class.getClassLoader().getResourceAsStream(resourceName)) { - ResourceBundle mimeBundle = ResourceBundle.getBundle(resourceName); - mimeBundle.keySet().stream() - .filter(x->x!=null) - .forEach(x-> - __dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(mimeBundle.getString(x)))); - - if (__dftMimeMap.size()==0) + if (stream == null) { - LOG.warn("Empty mime types at {}", resourceName); + LOG.warn("Missing mime-type resource: {}", resourceName); } - else if (__dftMimeMap.size()x!=null) + .forEach(x-> + __dftMimeMap.put(StringUtil.asciiToLowerCase(x), normalizeMimeType(props.getProperty(x)))); - resourceName = "org/eclipse/jetty/http/encoding"; - try - { - ResourceBundle encodingBundle = ResourceBundle.getBundle(resourceName); - encodingBundle.keySet().stream() - .filter(t->t!=null) - .forEach(t->__encodings.put(t, encodingBundle.getString(t))); + if (__dftMimeMap.size()==0) + { + LOG.warn("Empty mime types at {}", resourceName); + } + else if (__dftMimeMap.size()t!=null) + .forEach(t->__encodings.put(t, props.getProperty(t))); + + if (__encodings.size()==0) + { + LOG.warn("Empty encodings at {}", resourceName); + } + else if (__encodings.size()