diff --git a/src/java/org/apache/commons/lang3/text/StrLookup.java b/src/java/org/apache/commons/lang3/text/StrLookup.java index 2f1cef85b..6f94eedac 100644 --- a/src/java/org/apache/commons/lang3/text/StrLookup.java +++ b/src/java/org/apache/commons/lang3/text/StrLookup.java @@ -40,16 +40,19 @@ public abstract class StrLookup { /** * Lookup that always returns null. */ - private static final StrLookup NONE_LOOKUP; + private static final StrLookup NONE_LOOKUP; /** * Lookup that uses System properties. */ - private static final StrLookup SYSTEM_PROPERTIES_LOOKUP; + private static final StrLookup SYSTEM_PROPERTIES_LOOKUP; static { - NONE_LOOKUP = new MapStrLookup(null); - StrLookup lookup = null; + NONE_LOOKUP = new MapStrLookup(null); + StrLookup lookup = null; try { - lookup = new MapStrLookup(System.getProperties()); + final Map propMap = System.getProperties(); + @SuppressWarnings("unchecked") // System property keys and values are always Strings + final Map properties = (Map) propMap; + lookup = new MapStrLookup(properties); } catch (SecurityException ex) { lookup = NONE_LOOKUP; } @@ -77,7 +80,7 @@ public abstract class StrLookup { * * @return a lookup using system properties, not null */ - public static StrLookup systemPropertiesLookup() { + public static StrLookup systemPropertiesLookup() { return SYSTEM_PROPERTIES_LOOKUP; } @@ -90,7 +93,7 @@ public abstract class StrLookup { * @param map the map of keys to values, may be null * @return a lookup using the map, not null */ - public static StrLookup mapLookup(Map map) { + public static StrLookup mapLookup(Map map) { return new MapStrLookup(map); } @@ -124,7 +127,7 @@ public abstract class StrLookup { /** * Lookup implementation that uses a Map. */ - static class MapStrLookup extends StrLookup { + static class MapStrLookup extends StrLookup { /** Map keys are variable names and value. */ private final Map map;