Stripes

binding invalid Date as a key to Map<Date,Date> breaks the map invariant

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Release 1.5.1, Release 1.6
  • Fix Version/s: Release 1.5.2, Release 1.6
  • Component/s: None
  • Labels:
    None

Description

When binding an invalid Date (e.g. 'notadate') as a key to a Map<Date,Date> property of an action bean, the TypeConverter fails to convert, but errors are 'ignored', and a String object is added as akey of the map. This violates the map's invariant, and generates a ClassCastException.

checked in unit test that reproduces in r.1053 :
net.sourceforge.stripes.controller.InvalidDateKeyBreaksInvariant_STS_651#bindInvalidDateKeysInMapBreaksMapInvariant

The @Test annotation is currently commented out, in order to avoide breaking the build.

Activity

Hide
Remi VANKEISBELCK added a comment - 26/Mar/09 2:40 PM

Looks pretty tricky.

Check :
MapPropertyAccessor.getKey(NodeEvaluation) : at line 90, it attempts to use a Type Converter in order to convert the map's key.

The DateTypeConverter is used, and of course, it returns a validation error, but this one is ignored.
The converted value is used only if conversion succeeded without validation errors. Otherwise, it defaults to the node's "typed value", which in this case is a String.

This is because at parsing time, Stripes finds default basic datatypes using regexps.
See PropertyExpression, line 214.

Show
Remi VANKEISBELCK added a comment - 26/Mar/09 2:40 PM Looks pretty tricky. Check : MapPropertyAccessor.getKey(NodeEvaluation) : at line 90, it attempts to use a Type Converter in order to convert the map's key. The DateTypeConverter is used, and of course, it returns a validation error, but this one is ignored. The converted value is used only if conversion succeeded without validation errors. Otherwise, it defaults to the node's "typed value", which in this case is a String. This is because at parsing time, Stripes finds default basic datatypes using regexps. See PropertyExpression, line 214.
Hide
Ben Gunter added a comment - 15/Oct/09 2:00 PM

Fixed in r1160 (1.5.x) and r1161 (trunk)

Show
Ben Gunter added a comment - 15/Oct/09 2:00 PM Fixed in r1160 (1.5.x) and r1161 (trunk)

People

Vote (0)
Watch (0)

Dates

  • Created:
    25/Feb/09 3:50 PM
    Updated:
    04/Jan/11 1:58 PM
    Resolved:
    15/Oct/09 2:00 PM