@@ -65,8 +65,7 @@ public class Ctags {
65
65
private final Object syncRoot = new Object ();
66
66
private volatile boolean closing ;
67
67
private volatile boolean signalled ;
68
- private volatile Process ctags ;
69
- private volatile IOException startIOException ;
68
+ private Process ctags ;
70
69
private Thread errThread ;
71
70
private Thread outThread ;
72
71
private OutputStreamWriter ctagsIn ;
@@ -75,7 +74,6 @@ public class Ctags {
75
74
//default: setCtags(System.getProperty("org.opensolaris.opengrok.analysis.Ctags", "ctags"));
76
75
private String binary ;
77
76
private String CTagsExtraOptionsFile = null ;
78
- private ProcessBuilder processBuilder ;
79
77
80
78
private boolean junit_testing = false ;
81
79
@@ -124,8 +122,9 @@ public void close() throws IOException {
124
122
}
125
123
}
126
124
127
- private void initialize () throws IOException , InterruptedException {
125
+ private void initialize () throws IOException {
128
126
RuntimeEnvironment env = RuntimeEnvironment .getInstance ();
127
+ ProcessBuilder processBuilder ;
129
128
if (true ) {
130
129
List <String > command = new ArrayList <>();
131
130
@@ -330,62 +329,7 @@ private void initialize() throws IOException, InterruptedException {
330
329
processBuilder = new ProcessBuilder (command );
331
330
}
332
331
333
- Thread clientThread = Thread .currentThread ();
334
-
335
- startIOException = null ;
336
- // Start ctags on a separate, daemon thread in case start() blocks.
337
- Thread startThread = new Thread (() -> {
338
- try {
339
- Process newCtags = processBuilder .start ();
340
- LOGGER .log (Level .FINE , "Executed ctags command re t{0}" ,
341
- clientThread .getId ());
342
- synchronized (syncRoot ) {
343
- ctags = newCtags ;
344
- syncRoot .notify ();
345
- }
346
- } catch (IOException e ) {
347
- startIOException = e ;
348
- }
349
- });
350
- startThread .setDaemon (true );
351
- startThread .start ();
352
-
353
- // Set a timeout so the client thread does not wait indefinitely.
354
- ScheduledFuture startTimeout = schedExecutor .schedule (() -> {
355
- LOGGER .log (Level .FINE , "Ctags startTimeout executing re t{0}." ,
356
- clientThread .getId ());
357
- clientThread .interrupt ();
358
- /**
359
- * No point in interrupting startThread, since nothing it executes
360
- * is interruptible.
361
- */
362
- LOGGER .log (Level .FINE , "Ctags startTimeout executed." );
363
- }, CTAGSWAIT_S , TimeUnit .SECONDS );
364
-
365
- // Wait until startThread sets the ctags field, until timeout, or error.
366
- synchronized (syncRoot ) {
367
- while (ctags == null ) {
368
- if (startIOException != null ) {
369
- startTimeout .cancel (false );
370
- throw startIOException ;
371
- }
372
- try {
373
- syncRoot .wait (SIGNALWAIT_MS );
374
- } catch (InterruptedException e ) {
375
- LOGGER .log (Level .WARNING , "Ctags did not start--{0}" ,
376
- e .getMessage ());
377
- startTimeout .cancel (false );
378
- throw e ;
379
- }
380
- }
381
- }
382
-
383
- startTimeout .cancel (false );
384
- /*
385
- * If the timeout could not be truly canceled in time, then ignore it.
386
- */
387
- Thread .interrupted ();
388
-
332
+ ctags = processBuilder .start ();
389
333
ctagsIn = new OutputStreamWriter (ctags .getOutputStream ());
390
334
ctagsOut = new BufferedReader (new InputStreamReader (ctags .getInputStream ()));
391
335
0 commit comments