From b8f56a9803f905ac14012324c7a65c4f554bac10 Mon Sep 17 00:00:00 2001 From: Michael Peter Christen Date: Fri, 8 Jun 2012 10:20:43 +0200 Subject: [PATCH] npe bugfix --- .../yacy/kelondro/order/MergeIterator.java | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/source/net/yacy/kelondro/order/MergeIterator.java b/source/net/yacy/kelondro/order/MergeIterator.java index f4071c73b..8d0efdb44 100644 --- a/source/net/yacy/kelondro/order/MergeIterator.java +++ b/source/net/yacy/kelondro/order/MergeIterator.java @@ -143,14 +143,44 @@ public class MergeIterator implements CloneableIterator { public static CloneableIterator cascade(final Collection> iterators, final Order c, final Method merger, final boolean up) { // this extends the ability to combine two iterators // to the ability of combining a set of iterators - if (iterators == null) return null; - if (iterators.isEmpty()) return null; + if (iterators == null || iterators.isEmpty()) return new CloneableIterator(){ + @Override + public boolean hasNext() { + return false; + } + @Override + public A next() { + return null; + } + @Override + public void remove() { + } + @Override + public CloneableIterator clone(Object modifier) { + return this; + } + }; return cascade(iterators.iterator(), c, merger, up); } private static CloneableIterator cascade(final Iterator> iiterators, final Order c, final Method merger, final boolean up) { - if (iiterators == null) return null; - if (!(iiterators.hasNext())) return null; + if (iiterators == null || !(iiterators.hasNext())) return new CloneableIterator(){ + @Override + public boolean hasNext() { + return false; + } + @Override + public A next() { + return null; + } + @Override + public void remove() { + } + @Override + public CloneableIterator clone(Object modifier) { + return this; + } + }; final CloneableIterator one = iiterators.next(); if (!(iiterators.hasNext())) return one; assert merger != null;