@@ -392,8 +392,20 @@ public Definitions doCtags(String file) throws IOException,
392
392
*
393
393
* @param bufferTags tags file output
394
394
* @return definitions parsed from buffer
395
+ * @throws java.lang.InterruptedException
395
396
*/
396
- public Definitions testCtagsParser (String bufferTags ) {
397
+ public Definitions testCtagsParser (String bufferTags )
398
+ throws InterruptedException {
399
+
400
+ // Ensure output is magic-terminated as expected.
401
+ StringBuilder tagsBuilder = new StringBuilder (bufferTags );
402
+ if (!bufferTags .endsWith ("\n " )) {
403
+ tagsBuilder .append ("\n " );
404
+ }
405
+ tagsBuilder .append (CTAGS_FILTER_TERMINATOR );
406
+ tagsBuilder .append ("\n " );
407
+ bufferTags = tagsBuilder .toString ();
408
+
397
409
junit_testing = true ;
398
410
ctagsOut = new BufferedReader (new StringReader (bufferTags ));
399
411
ctags = new Process () {
@@ -429,11 +441,7 @@ public void destroy() {
429
441
430
442
CtagsReader rdr = new CtagsReader ();
431
443
rdr .setTabSize (tabSize );
432
- try {
433
- readTags (rdr );
434
- } catch (InterruptedException ex ) {
435
- LOGGER .log (Level .SEVERE , "readTags() test" , ex );
436
- }
444
+ readTags (rdr );
437
445
Definitions ret = rdr .getDefinitions ();
438
446
return ret ;
439
447
}
@@ -449,18 +457,22 @@ private void readTags(CtagsReader reader) throws InterruptedException {
449
457
//log.fine("Tagline:-->" + tagLine+"<----ONELINE");
450
458
if (tagLine == null ) {
451
459
if (!junit_testing ) {
452
- LOGGER .warning ("Unexpected end of file!" );
460
+ LOGGER .warning ("ctags: Unexpected end of file!" );
453
461
}
454
462
try {
455
463
int val = ctags .exitValue ();
456
464
if (!junit_testing ) {
457
465
LOGGER .log (Level .WARNING , "ctags exited with code: {0}" , val );
458
466
}
467
+ } catch (IllegalThreadStateException e ) {
468
+ LOGGER .log (Level .WARNING , "ctags EOF but did not exit" );
469
+ ctags .destroyForcibly ();
459
470
} catch (Exception e ) {
460
- LOGGER .log (Level .WARNING , "Ctags problem: " , e );
471
+ LOGGER .log (Level .WARNING , "ctags problem:" , e );
472
+ ctags .destroyForcibly ();
461
473
}
462
- LOGGER . fine ( "Ctag read" );
463
- return ;
474
+ // Throw the following to indicate non-I/O error for retry.
475
+ throw new InterruptedException ( "tagLine == null" ) ;
464
476
}
465
477
466
478
if (CTAGS_FILTER_TERMINATOR .equals (tagLine )) {
0 commit comments