File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed
main/java/org/apache/hugegraph/loader/reader/file
test/java/org/apache/hugegraph/loader/test/functional Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,14 @@ public Line fetch() throws IOException {
168168 if (this .needSkipLine (rawLine ) || this .checkMatchHeader (rawLine )) {
169169 continue ;
170170 }
171- return this .parser .parse (this .source ().header (), rawLine );
171+ String [] header = this .source ().header ();
172+ if (header == null ) {
173+ throw new LoadException ("Header is null when parsing line at offset %s, " +
174+ "this indicates a concurrency issue or initialization failure" ,
175+ this .offset ());
176+ }
177+
178+ return this .parser .parse (header , rawLine );
172179 }
173180 }
174181
@@ -230,9 +237,15 @@ private boolean checkMatchHeader(String line) {
230237 return false ;
231238 }
232239
233- assert this .source ().header () != null ;
240+ String [] header = this .source ().header ();
241+ if (header == null ) {
242+ LOG .warn ("Header is null when checking match for line at offset {}, " +
243+ "this should not happen in normal cases" , this .offset ());
244+ return false ;
245+ }
246+
234247 String [] columns = this .parser .split (line );
235- return Arrays .equals (this . source (). header () , columns );
248+ return Arrays .equals (header , columns );
236249 }
237250
238251 private static BufferedReader createBufferedReader (InputStream stream ,
Original file line number Diff line number Diff line change @@ -104,6 +104,11 @@ public List<InputReader> split() {
104104
105105 this .fetcher = this .createLineFetcher ();
106106 this .fetcher .readHeaderIfNeeded (readableList );
107+ if (this .source ().format ().needHeader () && this .source ().header () == null ) {
108+ throw new InitException ("Failed to initialize header for file source '%s'. " +
109+ "Header is required but was not read successfully." ,
110+ this .source );
111+ }
107112
108113 this .readables = readableList .iterator ();
109114 List <InputReader > readers = new ArrayList <>();
Original file line number Diff line number Diff line change @@ -1197,9 +1197,7 @@ public void testMultiFilesHaveHeader() {
11971197 "-s" , configPath ("multi_files_have_header/schema.groovy" ),
11981198 "-g" , GRAPH ,
11991199 "-h" , SERVER ,
1200- "--test-mode" , "true" ,
1201- // FIXME: Set parser-threads to 1 because values > 1 currently trigger a NullPointerException (NPE).
1202- "--parser-threads" , "1"
1200+ "--test-mode" , "true"
12031201 };
12041202 loadWithAuth (args );
12051203
@@ -1632,9 +1630,7 @@ public void testFilterPathBySuffix() {
16321630 "-s" , configPath ("filter_path_by_suffix/schema.groovy" ),
16331631 "-g" , GRAPH ,
16341632 "-h" , SERVER ,
1635- "--test-mode" , "true" ,
1636- // FIXME: Set parser-threads to 1 because values > 1 currently trigger a NullPointerException (NPE).
1637- "--parser-threads" , "1"
1633+ "--test-mode" , "true"
16381634 };
16391635 loadWithAuth (args );
16401636
You can’t perform that action at this time.
0 commit comments