You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by st...@apache.org on 2011/02/05 19:52:12 UTC
svn commit: r1067481 - in /myfaces/core/trunk/api/src:
main/java/javax/faces/convert/DoubleConverter.java
test/java/javax/faces/convert/DoubleConverterTest.java
Author: struberg
Date: Sat Feb 5 18:52:12 2011
New Revision: 1067481
URL: http://svn.apache.org/viewvc?rev=1067481&view=rev
Log:
MYFACES-3024 badValue parsing improved
We'll now throw a ConverterException for values
which might lead to a stale JVM. This is
better for the admins than to silently return 0...
Modified:
myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java
myfaces/core/trunk/api/src/test/java/javax/faces/convert/DoubleConverterTest.java
Modified: myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java?rev=1067481&r1=1067480&r2=1067481&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/convert/DoubleConverter.java Sat Feb 5 18:52:12 2011
@@ -146,11 +146,12 @@ public class DoubleConverter
normalized.append(c);
}
}
- if (normalized.toString().contains("22250738585072012"))
+
+ String normalizedString = normalized.toString();
+ if (normalizedString.contains("22250738585072012") && normalizedString.contains("e-"))
{
// oops, baaad value!
- // this is so low, that we just return zero instead...
- return 0.0d;
+ throw new NumberFormatException("Not Allowed! This value could possibly kill the VM!");
}
}
Modified: myfaces/core/trunk/api/src/test/java/javax/faces/convert/DoubleConverterTest.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/test/java/javax/faces/convert/DoubleConverterTest.java?rev=1067481&r1=1067480&r2=1067481&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/test/java/javax/faces/convert/DoubleConverterTest.java (original)
+++ myfaces/core/trunk/api/src/test/java/javax/faces/convert/DoubleConverterTest.java Sat Feb 5 18:52:12 2011
@@ -140,8 +140,15 @@ public class DoubleConverterTest extends
for (String badVal : baaadValues)
{
- d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, badVal);
- assertNotNull(d);
+ try
+ {
+ d = (Double) mock.getAsObject(FacesContext.getCurrentInstance(), input, badVal);
+ fail();
+ }
+ catch(ConverterException cex)
+ {
+ // all is well, we expect the Converter to detect the baaad values...
+ }
}
}