java.io.StreamCorruptedException: invalid type code: 00

后端 未结 6 1763
天命终不由人
天命终不由人 2020-11-27 08:43

So basically im writing a client-server multiplayer game. I have a SeverCommunicationThread that creates a gameThread if he receives a RequestForGame creates a gameThread.

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-11-27 08:53

    There's another possibility that I ran across where if you implement a custom deserialization routine for a class by adding this method:

    private void readObject( ObjectInputStream objectInputStream ) throws IOException
    

    then objectInputStream.defaultReadObject() must be called and called before any further reads of the input stream to properly initialise the object.

    I missed this and despite the object returning without an exception being thrown it was the next read of the object stream that confusingly raised the invalid type code exception.

    This link provides further information on the process: http://osdir.com/ml/java.sun.jini/2003-10/msg00204.html.

提交回复
热议问题