From 60d6d0a3d5ee7ee1bac08a644938533ba72af928 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 1 Nov 2012 09:41:52 -0400 Subject: [PATCH] Safer casting in java config parsing Java config parsing, in particular getString and getInt, no longer fail when encountering a number value in the internl JSON->Map object. Java does not allow the following cast: String s = (String) someNumber; Instead, rely on the object's toString() which is safe and guaranteed to exist. Signed-off-by: Bill Erickson Signed-off-by: Jason Stephenson --- src/java/org/opensrf/util/Config.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/java/org/opensrf/util/Config.java b/src/java/org/opensrf/util/Config.java index ddac9c0..526d863 100644 --- a/src/java/org/opensrf/util/Config.java +++ b/src/java/org/opensrf/util/Config.java @@ -78,7 +78,7 @@ public class Config { */ public String getString(String path) throws ConfigException { try { - return (String) get(path); + return get(path).toString(); } catch(Exception e) { throw new ConfigException("No config string found at " + path); -- 2.11.0