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.
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?
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.ibjectInputStream.readObject0(ObjectInputStream.java:1379)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.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.ibjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1379)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.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.ibjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.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.ibjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.ibjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.ibjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2618)
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at java.ibjectInputStream$BlockDataInputStream.readInt(ObjectInputStream.java:2823)
at java.ibjectInputStream.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.ibjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
at java.ibjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.ibjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.ibjectInputStream$BlockDataInputStream.read(ObjectInputStream.java:2618)
at java.io.DataInputStream.readInt(DataInputStream.java:387)
at java.ibjectInputStream$BlockDataInputStream.readInt(ObjectInputStream.java:2823)
at java.ibjectInputStream.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.ibjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1896)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.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.ibjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.ibjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.ibjectInputStream$BlockDataInputStream.skipBlockData(ObjectInputStream.java:2448)
at java.ibjectInputStream.skipCustomData(ObjectInputStream.java:1944)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1921)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
at java.ibjectInputStream$BlockDataInputStream.readBlockHeader(ObjectInputStream.java:2512)
at java.ibjectInputStream$BlockDataInputStream.refill(ObjectInputStream.java:2546)
at java.ibjectInputStream$BlockDataInputStream.skipBlockData(ObjectInputStream.java:2448)
at java.ibjectInputStream.skipCustomData(ObjectInputStream.java:1944)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1921)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.defaultReadFields(ObjectInputStream.java:1993)
at java.ibjectInputStream.readSerialData(ObjectInputStream.java:1918)
at java.ibjectInputStream.readOrdinaryObject(ObjectInputStream.java:1801)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1351)
at java.ibjectInputStream.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)
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.iptionalDataException
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1363)
at java.ibjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
at java.ibjectInputStream.readObject0(ObjectInputStream.java:1363)
at java.ibjectInputStream.readObject(ObjectInputStream.java:371)
at org.gnet.client.GNetClient.clientLoop(GNetClient.java:92)
at org.gnet.client.GNetClient$1.run(GNetClient.java:49)
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?