Friday, November 5, 2010

Can U Give A Cat Temazapam

Apache Commons Configuration and NumberFormatException - Bug in environment configuration in combination with CombinedConfiguration ...

When using the Apache Commons Configuration Library I am paired with a fault discovered in the use of environment configuration with CombinedConfiguration .
The error occurs when a key is included in parenthesis. Windows7 For 64bit systems, however, this is the norm with the environment variable Program Files (x86) .
The bug is already fixed, but only in the next, not yet released version 1.7 of Apache Commons Configuration.
https: having to / / issues.apache.org/jira/browse/CONFIGURATION-404
patch to not need the library I have the following little work around
private
abstract configuration getEnvConfig () {
/ / use of environment configuration is not possible: this tinkered! (Bug in
apache commons)

/ / see https: / / issues.apache.org/jira/browse/CONFIGURATION-404
Pattern p = Pattern.
compile
(
"[\\(\\)]"
);

    Map<String, String> envMap =
new

HashMap<String, String>();
    for (Entry<String, String> entry : System.
getenv
().entrySet()) {       String key = entry.getKey();
      if
(!p.matcher(key).find())
        envMap.put(key, entry.getValue());
    }

return
new
MapConfiguration (EnvMap); }

0 comments:

Post a Comment