From 166f59bd9586bb2e82c3fe698eebd07735d9ba1e Mon Sep 17 00:00:00 2001 From: Kevin Mader Date: Fri, 5 Dec 2014 16:41:35 +0100 Subject: [PATCH 1/2] changed to concurrent supported map --- .../java/org/scijava/annotations/AbstractIndexWriter.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java index 9266d6d26..836c1a25b 100644 --- a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java +++ b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java @@ -44,6 +44,7 @@ import java.util.Map; import java.util.Map.Entry; import java.util.TreeMap; +import java.util.concurrent.ConcurrentSkipListMap; /** * Writes annotations as JSON-formatted files. @@ -58,7 +59,7 @@ public abstract class AbstractIndexWriter { private final Map> map = - new TreeMap>(); + new ConcurrentSkipListMap>(); protected synchronized boolean foundAnnotations() { return !map.isEmpty(); @@ -135,7 +136,7 @@ protected synchronized void merge(final String annotationName, int changedCount = map.size(); boolean hasObsoletes = false; - final IndexReader reader = new IndexReader(in); + final IndexReader reader = new IndexReader(in,annotationName+" from "+in); try { for (;;) { @SuppressWarnings("unchecked") From 91829d081b7f8c155d8996c4f5d64095c71aacdf Mon Sep 17 00:00:00 2001 From: Kevin Mader Date: Wed, 21 Jan 2015 15:44:16 +0100 Subject: [PATCH 2/2] added new code to make debugging problems with the annotation processor easier --- .../org/scijava/annotations/IndexReader.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/scijava/annotations/IndexReader.java b/src/main/java/org/scijava/annotations/IndexReader.java index 3121bf4c1..5440ccde3 100644 --- a/src/main/java/org/scijava/annotations/IndexReader.java +++ b/src/main/java/org/scijava/annotations/IndexReader.java @@ -64,13 +64,23 @@ class IndexReader { private final PushbackInputStream in; + private final String originalISName; IndexReader(final InputStream in) { this.in = in instanceof PushbackInputStream ? (PushbackInputStream) in : new PushbackInputStream(new BufferedInputStream(in)); + this.originalISName=""; } + IndexReader(final InputStream in,final String isName) { + this.in = + in instanceof PushbackInputStream ? (PushbackInputStream) in + : new PushbackInputStream(new BufferedInputStream(in)); + this.originalISName=isName; + } + + public Object next() throws IOException { int c = in.read(); while (Character.isWhitespace(c)) c = in.read(); @@ -155,7 +165,8 @@ else if (c < '0' || c > '9') { if (c == '"') { return readString(); } - throw new IOException("Unexpected char: '" + (char) c + "'"); + throw new IOException("Unexpected char: '" + (char) c + "'"+ + ((originalISName.length()>0) ? " from "+originalISName : "")); } public void close() throws IOException { @@ -206,7 +217,7 @@ private int expect(char a, char b) throws IOException { return 1; } throw new IOException("Expected '" + a + "' or '" + b + "', got '" + - (char) c + "'"); + (char) c + "'"+((originalISName.length()>0) ? " from "+originalISName : "")); } private void expect(String match) throws IOException { @@ -217,6 +228,7 @@ private void expect(String match) throws IOException { private IndexReader() { this.in = null; + this.originalISName=""; } static IndexReader getLegacyReader(final InputStream in) throws IOException {