From: Bill Erickson Date: Thu, 1 Nov 2012 13:41:52 +0000 (-0400) Subject: Safer casting in java config parsing X-Git-Tag: osrf_rel_2_2_0-alpha~19 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d262e2892203dc74fcd1abc69a9ae7458566b18a;p=OpenSRF.git 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 Signed-off-by: Dan Scott --- 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);