]> WPIA git - gigi.git/commitdiff
chg: Explicitly bail on invalid lines in imported lists
authorBenny Baumann <BenBE1987@gmx.net>
Sun, 19 Mar 2017 23:19:20 +0000 (00:19 +0100)
committerBenny Baumann <BenBE1987@gmx.net>
Wed, 22 Mar 2017 21:47:31 +0000 (22:47 +0100)
Change-Id: I71afe609e7f736d2e6b7a032a7e971b3b770395a

util/club/wpia/gigi/util/HighFinancialValueFetcherAlexa.java
util/club/wpia/gigi/util/HighFinancialValueFetcherUmbrella.java

index ae3ef536b524ef6801af274cb1d974f40d73c4ab..398bde2006a15972b3b3ba268bcc8ce13353ab1d 100644 (file)
@@ -12,8 +12,16 @@ public class HighFinancialValueFetcherAlexa extends HighFinancialValueFetcher {
     @Override
     public void handle(String line, PrintWriter fos) {
         String[] parts = line.split(",");
+
         // Assert that the value before the "," is an integer
-        Integer.parseInt(parts[0]);
+        try {
+            if (Integer.parseInt(parts[0]) < 1) {
+                throw new NumberFormatException("We expect a number greater then zero for the first column.");
+            }
+        } catch (NumberFormatException nfe) {
+            // Bail on lines with invalid first field
+            throw new Error("Invalid format of first column.", nfe);
+        }
 
         emit(fos, parts[1]);
         System.out.println(parts[1]);
index 321c3df4b22cf4cd515e171ed88a915a5361a7d3..40662e3bf80eb21f8afde718f89fa6a89d50f579 100644 (file)
@@ -15,8 +15,16 @@ public class HighFinancialValueFetcherUmbrella extends HighFinancialValueFetcher
     @Override
     public void handle(String line, PrintWriter fos) {
         String[] parts = line.split(",");
+
         // Assert that the value before the "," is an integer
-        Integer.parseInt(parts[0]);
+        try {
+            if (Integer.parseInt(parts[0]) < 1) {
+                throw new NumberFormatException("We expect a number greater then zero for the first column.");
+            }
+        } catch (NumberFormatException nfe) {
+            // Bail on lines with invalid first field
+            throw new Error("Invalid format of first column.", nfe);
+        }
 
         String registrablePart = PublicSuffixes.getInstance().getRegistrablePart(parts[1]);
         if (registrablePart != null && printed.add(registrablePart)) {