You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2014/10/26 23:10:28 UTC
[Bug 57148] New: EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
https://issues.apache.org/bugzilla/show_bug.cgi?id=57148
Bug ID: 57148
Summary: EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
Product: Tomcat 8
Version: 8.0.14
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: EL
Assignee: dev@tomcat.apache.org
Reporter: knst.kolinko@gmail.com
(Noted when reviewing org.apache.el.lang.ELSupport.coerceToType())
My expectations are that ELSupport.coerceToType() method follows the type
conversion rules specified in Expression Language specification.
There is the following phrase in specification 3.0 ch.1.23.7 Coerce A to Any
Other Type T:
"If A is a String and T's PropertyEditor throws an exception:"
"If A is "", return null"
"Otherwise, error"
The same phrase in present in EL 2.2 and EL 2.1 specifications (ch.1.18.7) as
well.
Consider the following case:
- A is an empty string ("")
- T has a PropertyEditor
Expected behaviour:
- Call PropertyEditor with value of "".
- If it throws an exception, return null.
- Otherwise use the converted value.
try {
propertyEditor.setAsText("").getValue();
} catch (RuntimeException e) {
return null;
}
Actual implementation:
- It skips calling the PropertyEditor and immediately returns null.
if (obj instanceof String) {
if ("".equals(obj))
return null;
PropertyEditor editor = PropertyEditorManager.findEditor(type);
...
The PropertyEditor.setAsText(String) method is documented to throw
IllegalArgumentException on invalid values. I think that EL API expects an
ELException, so it is to be wrapped somewhere.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 57148] EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57148
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|EL |Jasper
Version|8.0.14 |trunk
Product|Tomcat 8 |Tomcat 7
Target Milestone|---- |---
OS| |All
--- Comment #2 from Mark Thomas <ma...@apache.org> ---
Added some unit tests that confirm the patch is correct and applied to 8.0.x
for 8.0.15 owards.
This needs to be back-ported so changing version.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 57148] EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57148
Mark Thomas <ma...@apache.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |FIXED
--- Comment #3 from Mark Thomas <ma...@apache.org> ---
Fixed in 7.0.x for 7.0.6 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 57148] EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57148
--- Comment #4 from Mark Thomas <ma...@apache.org> ---
Correction. 7.0.60 onwards.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org
[Bug 57148] EL type conversion of empty string when there is a
PropertyEditor (ELSupport.coerceToType())
Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=57148
--- Comment #1 from Konstantin Kolinko <kn...@gmail.com> ---
Created attachment 32147
--> https://issues.apache.org/bugzilla/attachment.cgi?id=32147&action=edit
2014-10-27_tc8_57148_v1.patch
Patch for current trunk. Not tested.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org