Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-33041

Dedicated server logs "java.io.IOException: The handle is invalid" on startup

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reopened
    • Resolution: Unresolved
    • Affects Version/s: Minecraft 13w39a, Minecraft 13w39b, Minecraft 13w41a, Minecraft 13w41b, Minecraft 13w42b, Minecraft 13w43a, Minecraft 1.7, Minecraft 1.7.1, Minecraft 1.7.2, Minecraft 13w47a, Minecraft 13w47b, Minecraft 13w47c, Minecraft 1.7.4, Minecraft 14w04b, Minecraft 14w05b, Minecraft 14w06a, Minecraft 1.7.5, Minecraft 14w11b, Minecraft 1.7.8, Minecraft 1.7.9, Minecraft 14w21b, Minecraft 14w28a, Minecraft 14w30b, Minecraft 1.8.1, Minecraft 1.8.3, Minecraft 1.8.8, Minecraft 15w51b, Minecraft 1.12.1, Minecraft 1.12.2 Pre-Release 1, Minecraft 1.12.2 Pre-Release 2, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 18w01a, Minecraft 1.13, Minecraft 19w11b, Minecraft 19w13b
    • Fix Version/s: None
    • Labels:
    • Confirmation Status:
      Confirmed
    • Category:
      (Unassigned)

      Description

      Moderator Note

      This error should not have any side effects and can be ignored (see section "Code analysis" for an explanation).
      When starting the server from the command line no error is logged, for example:

      java -Xmx1024M -Xms1024M -jar server.jar
      

      The bug

      When the dedicated server is started by double clicking the .jar file it logs the following error on startup:

      1.13
      [09:23:17 ERROR]: Exception handling console input
      java.io.IOException: The handle is invalid
      	at java.io.FileInputStream.readBytes(Native Method) ~[?:1.8.0_172]
      	at java.io.FileInputStream.read(Unknown Source) ~[?:1.8.0_172]
      	at java.io.BufferedInputStream.read1(Unknown Source) ~[?:1.8.0_172]
      	at java.io.BufferedInputStream.read(Unknown Source) ~[?:1.8.0_172]
      	at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[?:1.8.0_172]
      	at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[?:1.8.0_172]
      	at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[?:1.8.0_172]
      	at java.io.InputStreamReader.read(Unknown Source) ~[?:1.8.0_172]
      	at java.io.BufferedReader.fill(Unknown Source) ~[?:1.8.0_172]
      	at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.8.0_172]
      	at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.8.0_172]
      	at sn$2.run(SourceFile:107) [server.jar:?]
      

      Code analysis

      It seems that the reason for this is that the server can process commands provided from the command prompt (System.in) and independently from the JTextField. In case you do not start the server using the command prompt it still tries to read the input from it which is not possible. It appears that there is no way to prevent this because apparently System.in is not null by default and you cannot test if the readers can read without calling the reading methods and catching exceptions (which is the way it currently behaves).

      As suggested in this StackOverflow answer the method InputStream.available() could be used at the start to detect if System.in is usable. If the .jar is not started from command line, then this method throws the exception as well. In this case a warning or an info message could be logged (including the exception?) and only the GUI input could be used.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                razdom raz
              • Votes:
                37 Vote for this issue
                Watchers:
                17 Start watching this issue

                Dates

                • Created:
                  Updated:
                  CHK: