Revision: 1160
http://stripes.svn.sourceforge.net/stripes/?rev=1160&view=rev
Author: bengunter
Date: 2009-10-15 18:47:20 +0000 (Thu, 15 Oct 2009)
Log Message:
-----------
Fixed STS-651: binding invalid Date as a key to Map<Date,Date> breaks the map
invariant. If the value is not of a type that is assignable to the map's key
type, then do not bind a value and log a warning.
Modified Paths:
--------------
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
2009-10-15 17:28:45 UTC (rev 1159)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/bean/MapPropertyAccessor.java
2009-10-15 18:47:20 UTC (rev 1160)
@@ -55,8 +55,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);
+ }
}
/**
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