You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2012/10/04 10:25:10 UTC

svn commit: r1393952 - in /ofbiz/branches/release12.04: ./ applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Author: jleroux
Date: Thu Oct  4 08:25:09 2012
New Revision: 1393952

URL: http://svn.apache.org/viewvc?rev=1393952&view=rev
Log:
"Applied fix from trunk for revision: 1393948  " 
------------------------------------------------------------------------
r1393948 | jleroux | 2012-10-04 10:07:34 +0200 (jeu., 04 oct. 2012) | 17 lines

A patch from Paul Foxworthy "Recalculate Order causes NumberFormatException" https://issues.apache.org/jira/browse/OFBIZ-5046

On demo site, create a new order by using the URL https://demo-trunk.ofbiz.apache.org/ordermgr/control/orderentry

Enter any Product ID, e.g. GZ-1000
Enter a Quantity, e.g. 1
Click on Add To Order

Now click on Recalculate Order on the title bar of the Create Order screenlet
Check the logs. On the demo site, you can do this with the URL https://demo-trunk.ofbiz.apache.org/webtools/control/LogView

You will see:
Exception: java.lang.NumberFormatException Message: For input string: "i18n" ---- stack trace --------------------------------------------------------------- java.lang.NumberFormatException: For input string: "i18n" java.lang.NumberFormatException.forInputString(NumberFormatException.java:48) java.lang.Integer.parseInt(Integer.java:449) java.lang.Integer.parseInt(Integer.java:499) org.ofbiz.order.shoppingcart.ShoppingCartHelper.modifyCart(ShoppingCartHelper.java:673)

The problem is the suffix _i18n on the input elements. The code in modifycart assumes the last thing in the parameter names is a sequence number.
This problem is not as severe as OFBIZ-5045, because the exception is swallowed immediately and the cart is updated properly. Still, these exceptions slow down OFBiz and add noise to the logs.

------------------------------------------------------------------------


Modified:
    ofbiz/branches/release12.04/   (props changed)
    ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java

Propchange: ofbiz/branches/release12.04/
------------------------------------------------------------------------------
  Merged /ofbiz/trunk:r1393948

Modified: ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java?rev=1393952&r1=1393951&r2=1393952&view=diff
==============================================================================
--- ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java (original)
+++ ofbiz/branches/release12.04/applications/order/src/org/ofbiz/order/shoppingcart/ShoppingCartHelper.java Thu Oct  4 08:25:09 2012
@@ -667,7 +667,8 @@ public class ShoppingCartHelper {
         for(String parameterName : context.keySet()) {
             int underscorePos = parameterName.lastIndexOf('_');
 
-            if (underscorePos >= 0) {
+            // ignore localized date input elements, just use their counterpart without the _i18n suffix
+            if (underscorePos >= 0 && (!parameterName.endsWith("_i18n"))) {
                 try {
                     String indexStr = parameterName.substring(underscorePos + 1);
                     int index = Integer.parseInt(indexStr);