Woher kommen diese Exceptions (StreamCorruptedException,OptionalDataException)?

vinno

Mitglied
Hallo,
ich wollte ein kleines Serverspiel basteln und habe dafür die GNetLib (http://www.java-gaming.org/topics/iconified/34508/view.html) verwendet. Nun läuft alles einigermaßen. Doch, wenn mehr als 1 Client auf dem Server ist, werden manchmal folgende Exceptions geworfen.
java.io.StreamCorruptedException: invalid type code: 14
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1379)
at java.io_ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:371)
at java.util.HashMap.readObject(HashMap.java:1394)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io_ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
java.io.StreamCorruptedException: invalid type code: 00
at java.io_ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.io_ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.io_ObjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2618)
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at java.io_ObjectInputStream$BlockDataInputStream.readInt(ObjectInputStream.java:2823)
at java.io_ObjectInputStream.readInt(ObjectInputStream.java:972)
at java.util.HashMap.readObject(HashMap.java:1369)
at sun.reflect.GeneratedMethodAccessor7.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at java.io_ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
java.io.StreamCorruptedException: invalid type code: 01
at java.io_ObjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.io_ObjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.io_ObjectInputStream$BlockDataInputStream.skipBlockData(ObjectInputStream.java:2448)
at java.io_ObjectInputStream.skipCustomData(ObjectInputStream.java:1944)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1921)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.io_ObjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.io_ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
Exception in thread "AWT-EventQueue-0" java.util.ConcurrentModificationException
at java.util.LinkedList$ListItr.checkForComodification(LinkedList.java:966)
at java.util.LinkedList$ListItr.next(LinkedList.java:888)
at java.util.AbstractList.hashCode(AbstractList.java:540)
at java.util.Objects.hashCode(Objects.java:98)
at java.util.HashMap$Node.hashCode(HashMap.java:296)
at java.util.HashMap.hash(HashMap.java:338)
at java.util.HashMap.put(HashMap.java:611)
at java.util.HashSet.add(HashSet.java:219)
at java.util.AbstractCollection.addAll(AbstractCollection.java:344)
at java.util.HashSet.<init>(HashSet.java:119)
at greenfoot.collision.ColManager.makeCollisionObjects(ColManager.java:97)
at greenfoot.collision.ColManager.prepareForCollision(ColManager.java:115)
at greenfoot.collision.ColManager.getOneIntersectingObject(ColManager.java:186)
at greenfoot.World.getOneIntersectingObject(World.java:782)
at greenfoot.Actor.getOneIntersectingObject(Actor.java:931)
at greenfoot.Actor.isTouching(Actor.java:944)
at Player.addedToWorld(Player.java:26)
at greenfoot.World.addObject(World.java:412)
at Agario.start(Agario.java:73)
at Agario.<init>(Agario.java:22)
at ClientGUI$7.actionPerformed(ClientGUI.java:209)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2346)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6525)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3322)
at java.awt.Component.processEvent(Component.java:6290)
at java.awt.Container.processEvent(Container.java:2234)
at java.awt.Component.dispatchEventImpl(Component.java:4881)
at java.awt.Container.dispatchEventImpl(Container.java:2292)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4898)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4533)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4462)
at java.awt.Container.dispatchEventImpl(Container.java:2278)
at java.awt.Window.dispatchEventImpl(Window.java:2739)
at java.awt.Component.dispatchEvent(Component.java:4703)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:751)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:702)
at java.awt.EventQueue$3.run(EventQueue.java:696)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:724)
at java.awt.EventQueue$4.run(EventQueue.java:722)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:721)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
java.io_OptionalDataException
at java.io_ObjectInputStream.readObject0(ObjectInputStream.java:1363)
at java.io_ObjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
Diese tauchen einfach so auf. Also nicht immer bei der gleichen Aktion.
Ohne groß in meinen Code zu schauen (Mein Code ist sehr unübersichtlich und lang), wie kommen solche zustande / Was muss man falsch machen, um solch eine Exception zu provozieren?
 

Joose

Top Contributor
Die ConcurrentModificationException dürft ein Programmierfehler von dir sein. Schau dir einfach den StackTrace an der verrät dir genau wo im Code die Exception auftritt.

Zu den anderen Exception: Ob du oder einfach die Library "schuld" ist kann man schwer sagen.
Hier ein Link welcher erklärt wie es zum Beispiel zu einer StreamCorruptedException kommen kann: http://stackoverflow.com/questions/...uptedexception-invalid-stream-header-7371007e
Ansonsten selbst die Library debuggen und nach dem Problem suchen, oder direkt an den Entwickler der Lib wenden (am besten mit einen simplen Beispiel, welches die Probleme/Exceptions reproduziert)
 

Ähnliche Java Themen


Oben