ASF Bugzilla – Attachment 22354 Details for
Bug 43656
ELSupport.coerceToType won't handle null for java.lang.Number
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Testcase and fix for the Integer to Number issue
tomcat6_0_18-bug_43656_p2.diff (text/plain), 1.61 KB, created by
Nils Eckert
on 2008-08-03 06:56:10 UTC
(
hide
)
Description:
Testcase and fix for the Integer to Number issue
Filename:
MIME Type:
Creator:
Nils Eckert
Created:
2008-08-03 06:56:10 UTC
Size:
1.61 KB
patch
obsolete
>Index: java/org/apache/el/lang/ELSupport.java >=================================================================== >--- java/org/apache/el/lang/ELSupport.java (revision 682165) >+++ java/org/apache/el/lang/ELSupport.java (working copy) >@@ -343,7 +343,7 @@ > public final static Object coerceToType(final Object obj, final Class type) > throws IllegalArgumentException { > if (type == null || Object.class.equals(type) || >- (obj != null && type.equals(obj.getClass()))) { >+ (obj != null && type.isAssignableFrom(obj.getClass()))) { > return obj; > } > if (String.class.equals(type)) { >@@ -358,9 +358,6 @@ > if (Boolean.class.equals(type) || Boolean.TYPE == type) { > return coerceToBoolean(obj); > } >- if (obj != null && type.isAssignableFrom(obj.getClass())) { >- return obj; >- } > if (type.isEnum()) { > return coerceToEnum(obj, type); > } >Index: test/org/apache/el/lang/TestELSupport.java >=================================================================== >--- test/org/apache/el/lang/TestELSupport.java (revision 682132) >+++ test/org/apache/el/lang/TestELSupport.java (working copy) >@@ -56,6 +56,12 @@ > testIsSame(Float.valueOf(0.123456F)); > } > >+ public void testCoerceIntegerToNumber() { >+ Integer input = 4390241; >+ Object output = ELSupport.coerceToType(input, Number.class); >+ assertEquals(input, output); >+ } >+ > private static void testIsSame(Object value) { > assertEquals(value, ELSupport.coerceToNumber(value, value.getClass())); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 43656
:
21831
| 22354 |
22355
|
24144
|
24145
|
24692