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.
Linked issues
is duplicated by 36
Attachments
Comments 28
my 1.7.2 server was working fine until recently. I can log onto it but friends cant now. my server log looks same as reported by others. I would like to add that my Mozilla Foxfire recently updated to 25.0(x86en-US) and I also have Mozilla Maintenance Service that updated on the same day, Nov. 5th. I tried changing security on my browser but it had no effect.
I've been seeing this error in the logs since I updated to 1.7.2. I am using the minecraft_server.1.7.2.exe file to run the server on a Windows 7 64-bit machine with Java 1.7.0_45 64-bit. I can confirm that I am able to login successfully to the server, as are other users.
The way the error reads seems to be related to the display; the log and chat portion of the window remains blank the entire time the server is running, but the logs actively update. Running commands from the server window works as it should, and the normal feedback for running commands from the server window appears in the log. Other than the log (and chat) not displaying in the server GUI properly I have not seen any issues that seem to be related to this error.
I attached the server start-up leading into the error below for reference:
[07:33:43] [Server thread/INFO]: Starting minecraft server version 1.7.2
[07:33:43] [Server thread/INFO]: Loading properties
[07:33:43] [Server console handler/ERROR]: Exception handling console input
java.io.IOException: The handle is invalid
at java.io.FileInputStream.readBytes(Native Method) ~[?:1.7.0_45]
at java.io.FileInputStream.read(Unknown Source) ~[?:1.7.0_45]
at java.io.BufferedInputStream.read1(Unknown Source) ~[?:1.7.0_45]
at java.io.BufferedInputStream.read(Unknown Source) ~[?:1.7.0_45]
at sun.nio.cs.StreamDecoder.readBytes(Unknown Source) ~[?:1.7.0_45]
at sun.nio.cs.StreamDecoder.implRead(Unknown Source) ~[?:1.7.0_45]
at sun.nio.cs.StreamDecoder.read(Unknown Source) ~[?:1.7.0_45]
at java.io.InputStreamReader.read(Unknown Source) ~[?:1.7.0_45]
at java.io.BufferedReader.fill(Unknown Source) ~[?:1.7.0_45]
at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.7.0_45]
at java.io.BufferedReader.readLine(Unknown Source) ~[?:1.7.0_45]
at ll.run(SourceFile:78) [minecraft_server.1.7.2.exe:?]
Confirmed for
15w51b
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).
Could you please link from the description to the comment above
"[09:23:17] [Server thread/INFO]: Starting minecraft server version 13w41b
[09:23:17] [Server console handler/ERROR]: Exception handling console input"