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 @@ -168,7 +168,14 @@ public Line fetch() throws IOException {
if (this.needSkipLine(rawLine) || this.checkMatchHeader(rawLine)) {
continue;
}
return this.parser.parse(this.source().header(), rawLine);
String[] header = this.source().header();
if (header == null) {
throw new LoadException("Header is null when parsing line at offset %s, " +
"this indicates a concurrency issue or initialization failure",
this.offset());
}

return this.parser.parse(header, rawLine);
}
}

Expand Down Expand Up @@ -230,9 +237,15 @@ private boolean checkMatchHeader(String line) {
return false;
}

assert this.source().header() != null;
String[] header = this.source().header();
if (header == null) {
LOG.warn("Header is null when checking match for line at offset {}, " +
"this should not happen in normal cases", this.offset());
return false;
}

String[] columns = this.parser.split(line);
return Arrays.equals(this.source().header(), columns);
return Arrays.equals(header, columns);
}

private static BufferedReader createBufferedReader(InputStream stream,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ public List<InputReader> split() {

this.fetcher = this.createLineFetcher();
this.fetcher.readHeaderIfNeeded(readableList);
if (this.source().format().needHeader() && this.source().header() == null) {
throw new InitException("Failed to initialize header for file source '%s'. " +
"Header is required but was not read successfully.",
this.source);
}

this.readables = readableList.iterator();
List<InputReader> readers = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1197,9 +1197,7 @@ public void testMultiFilesHaveHeader() {
"-s", configPath("multi_files_have_header/schema.groovy"),
"-g", GRAPH,
"-h", SERVER,
"--test-mode", "true",
// FIXME: Set parser-threads to 1 because values > 1 currently trigger a NullPointerException (NPE).
"--parser-threads", "1"
"--test-mode", "true"
};
loadWithAuth(args);

Expand Down Expand Up @@ -1632,9 +1630,7 @@ public void testFilterPathBySuffix() {
"-s", configPath("filter_path_by_suffix/schema.groovy"),
"-g", GRAPH,
"-h", SERVER,
"--test-mode", "true",
// FIXME: Set parser-threads to 1 because values > 1 currently trigger a NullPointerException (NPE).
"--parser-threads", "1"
"--test-mode", "true"
};
loadWithAuth(args);

Expand Down
Loading