From: David ‘Bombe’ Roden Date: Wed, 28 Jan 2015 05:28:17 +0000 (+0100) Subject: Prevent empty or formatted strings from being parsed as a number. X-Git-Tag: v2~209 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=3b2babd4a444199df947ed9d2460a1e9b58581a6;p=rhynodge.git Prevent empty or formatted strings from being parsed as a number. --- diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java index 57be6f0..2b071c0 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/torrents/TorrentzEuFilter.java @@ -46,12 +46,19 @@ public class TorrentzEuFilter extends TorrentSiteFilter { @Override protected int extractSeedCount(Element dataRow) { - return Integer.valueOf(dataRow.select("dd span.u").text()); + return extractNumber(dataRow.select("dd span.u").text()); } @Override protected int extractLeechCount(Element dataRow) { - return Integer.valueOf(dataRow.select("dd span.d").text()); + return extractNumber(dataRow.select("dd span.d").text()); + } + + private int extractNumber(String text) { + if ((text == null) || text.isEmpty()) { + return 0; + } + return Integer.valueOf(text.replace(",", "")); } }