Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -60,7 +61,7 @@
public abstract class AbstractIndexWriter {

private final Map<String, Map<String, Object>> map =
new TreeMap<String, Map<String, Object>>();
new ConcurrentSkipListMap<String, Map<String, Object>>();

protected synchronized boolean foundAnnotations() {
return !map.isEmpty();
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 14 additions & 2 deletions src/main/java/org/scijava/annotations/IndexReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down