[PATCH] Avoid NPE: fixRes is null if wqkms.lenght==0

Wald Commits scm-commit at wald.intevation.org
Thu Apr 23 19:06:58 CEST 2015


# HG changeset patch
# User Tom Gottfried <tom at intevation.de>
# Date 1429808801 -7200
# Node ID e4f9e2316e92813f819e4761036f8d177ea287b0
# Parent  582aaac447adbe8adc71424841287a0d2e60cdf4
Avoid NPE: fixRes is null if wqkms.lenght==0.

diff -r 582aaac447ad -r e4f9e2316e92 artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Thu Apr 23 16:42:42 2015 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/fixation/FixRealizingCompute.java	Thu Apr 23 19:06:41 2015 +0200
@@ -136,22 +136,24 @@
             }
         }
 
-        DateFormat df = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy");
-        DateFormat lf = Formatter.getDateFormatter(context.getMeta(), "dd.MM.yyyy'T'HH:mm");
+        if (wqkms.length > 0) {
+            DateFormat df = Formatter.getDateFormatter(context.getMeta(),
+                "dd.MM.yyyy");
+            DateFormat lf = Formatter.getDateFormatter(context.getMeta(),
+                "dd.MM.yyyy'T'HH:mm");
 
-        Collection<Date> reds = fixRes.getReferenceEventsDates();
-        UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds);
+            Collection<Date> reds = fixRes.getReferenceEventsDates();
+            UniqueDateFormatter cf = new UniqueDateFormatter(df, lf, reds);
 
-        int i = 0;
-        for (Date d: reds) {
-            facets.add(new FixReferenceEventsFacet(
-                (1 << 9) | i,
-                FIX_EVENTS,
-                cf.format(d)));
-            i++;
-        }
+            int i = 0;
+            for (Date d: reds) {
+                facets.add(new FixReferenceEventsFacet(
+                        (1 << 9) | i,
+                    FIX_EVENTS,
+                    cf.format(d)));
+                i++;
+            }
 
-        if (wqkms.length > 0) {
             facets.add(
                 new DataFacet(CSV, "CSV data", ComputeType.ADVANCE, hash, id));
 


More information about the Dive4Elements-commits mailing list