Skip to content

Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance

better fix for NPE in image search replace https://gitorious.org/yacy/rc1/commit/8931e14514deff5ab66e7504c45bb78046e5f696

regerffa7c7116f9f
diff --git a/source/net/yacy/search/query/SearchEvent.java b/source/net/yacy/search/query/SearchEvent.java
index 077eaec61..7ac36955c 100644
--- a/source/net/yacy/search/query/SearchEvent.java
+++ b/source/net/yacy/search/query/SearchEvent.java
@@ -1567,8 +1567,8 @@ public final class SearchEvent {
List<String> prt = CollectionConfiguration.indexedList2protocolList(doc.getFieldValues(CollectionSchema.images_protocol_sxt.getSolrFieldName()), img.size());
Collection<Object> heightO = doc.getFieldValues(CollectionSchema.images_height_val.getSolrFieldName());
Collection<Object> widthO = doc.getFieldValues(CollectionSchema.images_width_val.getSolrFieldName());
- List<Object> height = heightO == null ? new ArrayList<Object>(img.size()) : (List<Object>) heightO;
- List<Object> width = widthO == null ? new ArrayList<Object>(img.size()) : (List<Object>) widthO;
+ List<Object> height = heightO == null ? null : (List<Object>) heightO;
+ List<Object> width = widthO == null ? null : (List<Object>) widthO;
for (int c = 0; c < img.size(); c++) {
String image_urlstub = (String) img.get(c);
if (image_urlstub.endsWith(".ico")) continue; // we don't want favicons, makes the result look idiotic
@@ -1576,8 +1576,8 @@ public final class SearchEvent {
boolean match = (query.getQueryGoal().matches(image_urlstub) || query.getQueryGoal().matches(image_alt));
try {
DigestURL imageUrl = new DigestURL((prt != null && prt.size() > c ? prt.get(c) : "http") + "://" + image_urlstub);
- Integer h = (Integer) height.get(c);
- Integer w = (Integer) width.get(c);
+ Integer h = height == null ? null : (Integer) height.get(c);
+ Integer w = width == null ? null : (Integer) width.get(c);
boolean sizeok = h != null && w != null && h.intValue() > 16 && w.intValue() > 16;
String id = ASCII.String(imageUrl.hash());
if (!imageViewed.containsKey(id) && !containsSpare(id)) {