public void run()

in surefire-booter/src/main/java/org/apache/maven/surefire/booter/CommandReader.java [285:349]


        public void run() {
            CommandReader.this.startMonitor.countDown();
            boolean isTestSetFinished = false;
            try (MasterProcessChannelDecoder commandReader = CommandReader.this.decoder) {
                while (CommandReader.this.state.get() == RUNNABLE) {
                    Command command = commandReader.decode();
                    switch (command.getCommandType()) {
                        case RUN_CLASS:
                            String test = command.getData();
                            boolean inserted = CommandReader.this.insertToQueue(test);
                            if (inserted) {
                                CommandReader.this.wakeupIterator();
                                callListeners(command);
                            }
                            break;
                        case TEST_SET_FINISHED:
                            CommandReader.this.makeQueueFull();
                            isTestSetFinished = true;
                            CommandReader.this.wakeupIterator();
                            callListeners(command);
                            break;
                        case SHUTDOWN:
                            CommandReader.this.makeQueueFull();
                            CommandReader.this.wakeupIterator();
                            callListeners(command);
                            break;
                        case BYE_ACK:
                            callListeners(command);
                            // After SHUTDOWN no more commands can come.
                            // Hence, do NOT go back to blocking in I/O.
                            CommandReader.this.state.set(TERMINATED);
                            break;
                        default:
                            callListeners(command);
                            break;
                    }
                }
            } catch (EOFException | ClosedChannelException e) {
                CommandReader.this.state.set(TERMINATED);
                if (!isTestSetFinished) {
                    String msg = "TestSet has not finished before stream error has appeared >> "
                            + "initializing exit by non-null configuration: "
                            + CommandReader.this.shutdown;
                    DumpErrorSingleton.getSingleton().dumpStreamException(e, msg);

                    exitByConfiguration();
                    // does not go to finally for non-default config: Shutdown.EXIT or Shutdown.KILL
                }
            } catch (IOException e) {
                CommandReader.this.state.set(TERMINATED);
                // If #stop() method is called, reader thread is interrupted
                // and exception is InterruptedIOException or its cause is InterruptedException.
                if (!(e instanceof InterruptedIOException || e.getCause() instanceof InterruptedException)) {
                    String msg = "[SUREFIRE] std/in stream corrupted";
                    DumpErrorSingleton.getSingleton().dumpStreamException(e, msg);
                    CommandReader.this.logger.error(msg, e);
                }
            } finally {
                // ensure fail-safe iterator as well as safe to finish in for-each loop using ClassesIterator
                if (!isTestSetFinished) {
                    CommandReader.this.makeQueueFull();
                }
                CommandReader.this.wakeupIterator();
            }
        }