commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r588329 - in /commons/proper/configuration/trunk: src/java/org/apache/commons/configuration/interpol/ConstantLookup.java src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java xdocs/changes.xml
Date Thu, 25 Oct 2007 20:01:32 GMT
Author: oheger
Date: Thu Oct 25 13:01:31 2007
New Revision: 588329

URL: http://svn.apache.org/viewvc?rev=588329&view=rev
Log:
CONFIGURATION-299: Fix for ClassCastExceptions in ConstantLookup when resolving non-String
variables

Modified:
    commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConstantLookup.java
    commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java
    commons/proper/configuration/trunk/xdocs/changes.xml

Modified: commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConstantLookup.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConstantLookup.java?rev=588329&r1=588328&r2=588329&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConstantLookup.java
(original)
+++ commons/proper/configuration/trunk/src/java/org/apache/commons/configuration/interpol/ConstantLookup.java
Thu Oct 25 13:01:31 2007
@@ -107,9 +107,8 @@
                 {
                     // In worst case, the value will be fetched multiple times
                     // because of this lax synchronisation, but for constant
-                    // values
-                    // this shouldn't be a problem.
-                    constantCache.put(var, value);
+                    // values this shouldn't be a problem.
+                    constantCache.put(var, String.valueOf(value));
                 }
                 result = value.toString();
             }

Modified: commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java?rev=588329&r1=588328&r2=588329&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java
(original)
+++ commons/proper/configuration/trunk/src/test/org/apache/commons/configuration/interpol/TestConstantLookup.java
Thu Oct 25 13:01:31 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.commons.configuration.interpol;
 
+import java.awt.event.KeyEvent;
+
 import junit.framework.TestCase;
 
 /**
@@ -119,5 +121,18 @@
     {
         testLookupConstant();
         testLookupConstant();
+    }
+
+    /**
+     * Tests resolving a non string constant. Then looks the same variable up
+     * from the cache.
+     */
+    public void testLookupNonStringFromCache()
+    {
+        final String var = KeyEvent.class.getName() + ".VK_ESCAPE";
+        final String expected = String.valueOf(KeyEvent.VK_ESCAPE);
+        assertEquals("Wrong result of first lookup", expected, lookup
+                .lookup(var));
+        assertEquals("Wrong result of 2nd lookup", expected, lookup.lookup(var));
     }
 }

Modified: commons/proper/configuration/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/xdocs/changes.xml?rev=588329&r1=588328&r2=588329&view=diff
==============================================================================
--- commons/proper/configuration/trunk/xdocs/changes.xml (original)
+++ commons/proper/configuration/trunk/xdocs/changes.xml Thu Oct 25 13:01:31 2007
@@ -23,6 +23,11 @@
 
   <body>
     <release version="1.5-SNAPSHOT" date="in SVN" description="">
+      <action dev="oheger" type="fix" issue="CONFIGURATION-299">
+        Resolving of variables with the prefix const (constant fields) caused
+        a ClassCastException under certain circumstances if non-String fields
+        were involved. This has been fixed.
+      </action>
       <action dev="oheger" type="update" due-to="Nicolas De Loof">
         The dependencies to commons-codec and commons-jxpath have been marked
         as optional. They are not required by the core classes.



Mime
View raw message