Revision: 1161
          http://stripes.svn.sourceforge.net/stripes/?rev=1161&view=rev
Author:   bengunter
Date:     2009-10-15 18:58:19 +0000 (Thu, 15 Oct 2009)

Log Message:
-----------
Applied fix for STS-651 from the 1.5.x branch.

Modified Paths:
--------------
    trunk/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
    
trunk/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java    
    2009-10-15 18:47:20 UTC (rev 1160)
+++ 
trunk/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java    
    2009-10-15 18:58:19 UTC (rev 1161)
@@ -54,8 +54,22 @@
      * @param value the value to be stored in the map under the specified key
      */
     @SuppressWarnings("unchecked")
-       public void setValue(NodeEvaluation evaluation, Map map, Object value) {
-        map.put(getKey(evaluation), value);
+    public void setValue(NodeEvaluation evaluation, Map map, Object value) {
+        Object key = getKey(evaluation);
+        if (key != null && 
!evaluation.getKeyType().isAssignableFrom(key.getClass())) {
+            String exprString = 
evaluation.getExpressionEvaluation().getExpression().getSource();
+            String nodeString = evaluation.getNode().getStringValue();
+            String declTypeName = evaluation.getKeyType().getName();
+            String evalTypeName = key.getClass().getName();
+            log.warn("Unable to bind ", exprString, " because the string \"", 
nodeString,
+                    "\" evaluates to a ", evalTypeName,
+                    ", which is not assignable to the map's key type of ", 
declTypeName,
+                    ". This likely means type conversion failed and there is 
no constructor ",
+                    declTypeName, "(String).");
+        }
+        else {
+            map.put(key, value);
+        }
     }
 
     /**

Modified: 
trunk/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
===================================================================
--- 
trunk/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
       2009-10-15 18:47:20 UTC (rev 1160)
+++ 
trunk/tests/src/net/sourceforge/stripes/controller/InvalidDateKeyBreaksInvariant_STS_651.java
       2009-10-15 18:58:19 UTC (rev 1161)
@@ -1,6 +1,7 @@
 package net.sourceforge.stripes.controller;
 
 import org.testng.Assert;
+import org.testng.annotations.Test;
 import net.sourceforge.stripes.mock.MockRoundtrip;
 import net.sourceforge.stripes.mock.MockServletContext;
 import net.sourceforge.stripes.StripesTestFixture;
@@ -19,7 +20,7 @@
         return new MockRoundtrip(context, MapBindingTests.class);
     }
 
-    //@Test
+    @Test
     public void bindInvalidDateKeysInMapBreaksMapInvariant() throws Exception {
         MockRoundtrip trip = getRoundtrip();
         trip.addParameter("mapDateDate['notadate']", "01/01/2000");


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to