diff --git a/src/main/java/org/scijava/annotations/AbstractIndexWriter.java b/src/main/java/org/scijava/annotations/AbstractIndexWriter.java index 52104745b..b208bf04d 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; import javax.lang.model.element.AnnotationValue; @@ -60,7 +61,7 @@ public abstract class AbstractIndexWriter { private final Map> map = - new TreeMap>(); + new ConcurrentSkipListMap>(); protected synchronized boolean foundAnnotations() { return !map.isEmpty(); @@ -137,7 +138,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") 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 {