[jboss-svn-commits] JBL Code SVN: r27457 - labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 2 15:15:44 EDT 2009


Author: KrisVerlaenen
Date: 2009-07-02 15:15:44 -0400 (Thu, 02 Jul 2009)
New Revision: 27457

Modified:
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
Log:
JBRULES-2155: Make parsing of bendpoints more error-safe
 - made parsing more error-safe

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java	2009-07-02 19:13:02 UTC (rev 27456)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java	2009-07-02 19:15:44 UTC (rev 27457)
@@ -90,8 +90,20 @@
         s = s.substring(1, s.length() - 1);
         String[] bendpoints = s.split(";");
         for (String bendpoint: bendpoints) {
-            String[] xy = bendpoint.split(",");
-            result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
+        	bendpoint = bendpoint.trim();
+        	if (bendpoint.length() != 0) { 
+        		String[] xy = bendpoint.split(",");
+        		if (xy.length != 2) {
+        			throw new IllegalArgumentException(
+    					"Unexpected bendpoint: " + bendpoint + " for bendpoints " + bendpoints +
+    					" - nb points = " + xy.length);
+        		}
+        		try {
+        			result.add(new Point(new Integer(xy[0]), new Integer(xy[1])));
+        		} catch (NumberFormatException e) {
+        			throw new IllegalArgumentException("Could not parse bendpoint " + bendpoint, e);
+        		}
+        	}
         }
         return result;
     }




More information about the jboss-svn-commits mailing list