From 6e13670a3e5d58b4af02d9d8043cd6978b52f834 Mon Sep 17 00:00:00 2001 From: mishako Date: Sat, 25 Nov 2017 09:36:18 +0100 Subject: [PATCH] Handle malformed values in itunes module (#370) See commit 943c0db. --- .../modules/itunes/io/ITunesParser.java | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java index 7c3917d65..fa7ca7106 100644 --- a/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java +++ b/rome-modules/src/main/java/com/rometools/modules/itunes/io/ITunesParser.java @@ -143,22 +143,31 @@ public com.rometools.rome.feed.module.Module parse(final Element element, final final Element order = element.getChild("order", ns); if (order != null && order.getValue() != null) { - final Integer o = Integer.valueOf(order.getValue().trim()); - entryInfo.setOrder(o); + try { + entryInfo.setOrder(Integer.valueOf(order.getValue().trim())); + } catch (NumberFormatException e) { + LOG.warn("Failed to parse order: {}", order.getValue()); + } } final Element season = element.getChild("season", ns); if (season != null && season.getValue() != null) { - final Integer o = Integer.valueOf(season.getValue().trim()); - entryInfo.setSeason(o); + try { + entryInfo.setSeason(Integer.valueOf(season.getValue().trim())); + } catch (NumberFormatException e) { + LOG.warn("Failed to parse season: {}", season.getValue()); + } } final Element episode = element.getChild("episode", ns); if (episode != null && episode.getValue() != null) { - final Integer o = Integer.valueOf(episode.getValue().trim()); - entryInfo.setEpisode(o); + try { + entryInfo.setEpisode(Integer.valueOf(episode.getValue().trim())); + } catch (NumberFormatException e) { + LOG.warn("Failed to parse episode: {}", episode.getValue()); + } } final Element episodeType = element.getChild("episodeType", ns);