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

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • 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, 1.14.4, 19w42a, 1.15.2, 20w18a, 20w19a, 1.18.1, 22w03a, 1.18.2, 1.19, 1.19.2, 22w42a, 1.20.1, 1.20.2, 24w12a, 1.21, 1.21.1, 1.21.3
    • Confirmed
    • Dedicated Server
    • Low
    • Platform

      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.

        1. latest.log
          4 kB
        2. MC-33041.png
          MC-33041.png
          19 kB
        3. server log.txt
          1 kB

            Unassigned Unassigned
            razdom raz
            Votes:
            47 Vote for this issue
            Watchers:
            25 Start watching this issue

              Created:
              Updated:
              CHK: