Skip to content

Commit

Permalink
Added nullcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
Cédric Dutoit committed Oct 12, 2017
1 parent 189b133 commit 550f2ac
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/main/java/ch/mno/copper/collect/WebCollector.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static List<String> query(String url, String username, String password, L
results = extractValues(data, valuesKept);
} catch (Exception e) {
System.err.println("Connector exception (server " + url+ "): " + e.getMessage());
e.printStackTrace();
if (results==null) {
results = new ArrayList<>(valuesKept.size());
}
Expand Down Expand Up @@ -100,7 +101,9 @@ else if ("contentType".equals(key)) {
results.add(res.get(0).toString());
}
} else if (o instanceof String) {
results.add((String)o);
results.add((String) o);
} else if (o==null) {
results.add("null");
} else {
results.add(o.toString());
}
Expand All @@ -113,12 +116,5 @@ else if ("contentType".equals(key)) {
return results;
}

public static void main(String[] args) {
List<Pair<String, String>> values = new ArrayList<>();
values.add(new ImmutablePair<>("responseCode", "rs"));
values.add(new ImmutablePair<>("status", "s"));
WebCollector.query("http://tom.etat-de-vaud.ch:1530/ws/infra/status", null, null, values);
}

}

0 comments on commit 550f2ac

Please sign in to comment.