better fix for NPE in image search

replace 8931e14514
This commit is contained in:
reger 2014-09-16 16:43:17 +02:00
parent b9de39be11
commit ffa7c7116f

View File

@ -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)) {