fix NPE in JSON writer
This commit is contained in:
parent
dcbe694669
commit
a98816e315
3 changed files with 11 additions and 5 deletions
|
@ -156,8 +156,8 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo
|
|||
writer.write(sb.toString());
|
||||
sb.setLength(0);
|
||||
recordCounter.incrementAndGet();
|
||||
} catch (IOException e) {
|
||||
handleException(e);
|
||||
} catch (Exception e) {
|
||||
handleException(new IOException(e));
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
|
@ -312,9 +312,13 @@ public class MarcJsonWriter extends MarcContentHandler implements Flushable, Clo
|
|||
c00++;
|
||||
}
|
||||
sb.append("]");
|
||||
} else {
|
||||
if (o == null) {
|
||||
sb.append("null");
|
||||
} else {
|
||||
sb.append("\"").append(escape(o.toString())).append("\"");
|
||||
}
|
||||
}
|
||||
c0++;
|
||||
}
|
||||
sb.append('}');
|
||||
|
|
|
@ -20,6 +20,8 @@ import static org.junit.Assert.assertEquals;
|
|||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.xbib.marc.Marc;
|
||||
import org.xbib.marc.MarcXchangeConstants;
|
||||
import org.xbib.marc.json.MarcJsonWriter;
|
||||
import org.xbib.marc.xml.MarcXchangeWriter;
|
||||
|
||||
|
|
Loading…
Reference in a new issue