fix NPE in location search on missing/empty PubDate in underlaying rss data

pull/1/head
reger 10 years ago
parent c1dcc8c456
commit b1ec0644e5

@ -113,7 +113,7 @@ public class yacysearch_location {
prop.put("kml_placemark_" + placemarkCounter + "_copyright", message.getCopyright());
prop.put("kml_placemark_" + placemarkCounter + "_subject", message.getSubject());
prop.put("kml_placemark_" + placemarkCounter + "_description", message.getDescriptions().size() > 0 ? message.getDescriptions().get(0) : "");
prop.put("kml_placemark_" + placemarkCounter + "_date", message.getPubDate());
prop.put("kml_placemark_" + placemarkCounter + "_date", (message.getPubDate() != null) ? message.getPubDate() : new Date());
prop.putXML("kml_placemark_" + placemarkCounter + "_url", message.getLink());
prop.put("kml_placemark_" + placemarkCounter + "_pointname", message.getTitle());
prop.put("kml_placemark_" + placemarkCounter + "_lon", lo);

@ -212,9 +212,13 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
return Token.language.valueFrom(this.map, "");
}
/**
* @return publishDate or null
*/
@Override
public Date getPubDate() {
final String dateString = Token.pubDate.valueFrom(this.map, "");
if (!dateString.isEmpty()) { // skip parse exception on empty string
Date date;
try {
date = HeaderFramework.FORMAT_RFC1123.parse(dateString);
@ -222,11 +226,13 @@ public class RSSMessage implements Hit, Comparable<RSSMessage>, Comparator<RSSMe
try {
date = GenericFormatter.SHORT_SECOND_FORMATTER.parse(dateString);
} catch (final ParseException e1) {
date = HeaderFramework.parseHTTPDate(dateString);
date = HeaderFramework.parseHTTPDate(dateString); // returns null on parse error
}
}
return date;
}
return null;
}
@Override
public String getGuid() {

Loading…
Cancel
Save