changeset 556:046f43e1d305

Avoid NPE while parsing axes in ChartInfoService. flys-client/trunk@2080 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 08 Jun 2011 12:43:38 +0000
parents 33b86f5b1168
children 92c200887b20
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java
diffstat 2 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Jun 08 10:57:28 2011 +0000
+++ b/flys-client/ChangeLog	Wed Jun 08 12:43:38 2011 +0000
@@ -1,3 +1,9 @@
+2011-06-08  Ingo Weinzierl <ingo@intevation.de>
+
+	* src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java:
+	  Skip axes that lay out of valid bounds. E.g. there are 2 axes: if one of
+	  those axes position is > 1 it is skipped.
+
 2011-06-08	Sascha L. Teichmann	<sascha.teichmann@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/client/ui/chart/ChartOutputTab.java:
--- a/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java	Wed Jun 08 10:57:28 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/server/ChartInfoServiceImpl.java	Wed Jun 08 12:43:38 2011 +0000
@@ -78,7 +78,10 @@
             return parseInfoDocument(info);
         }
         catch (IOException ioe) {
-            // do nothing
+            ioe.printStackTrace();
+        }
+        catch (Exception e) {
+            e.printStackTrace();
         }
 
         System.err.println("Error while fetching chart info.");
@@ -152,6 +155,12 @@
                 double from = Double.parseDouble(fromStr);
                 double to   = Double.parseDouble(toStr);
 
+                if (pos >= result.length) {
+                    // this should never happen
+                    System.err.println("The axis is out of valid range: " + pos);
+                    continue;
+                }
+
                 result[pos] = new Axis(pos, from, to);
             }
             catch (NumberFormatException nfe) {

http://dive4elements.wald.intevation.org