1

我的 android 应用程序在这部分代码崩溃:

ois = new ObjectInputStream(socket.getInputStream());
Object obj = ois.readObject();

调用函数 readObject() 时。

它工作了几个小时没有问题,然后发生了这种情况:

07-03 07:52:34.409: E/AndroidRuntime(1600): FATAL EXCEPTION: Thread-215
07-03 07:52:34.409: E/AndroidRuntime(1600): java.lang.IndexOutOfBoundsException: Invalid index 1937902936, size is 28
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.util.ArrayList.get(ArrayList.java:304)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.registeredObjectRead(ObjectInputStream.java:2157)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readCyclicReference(ObjectInputStream.java:833)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:692)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1799)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1999)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1956)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.util.concurrent.CopyOnWriteArrayList.readObject(CopyOnWriteArrayList.java:766)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.lang.reflect.Method.invokeNative(Native Method)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.lang.reflect.Method.invoke(Method.java:511)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readObjectForClass(ObjectInputStream.java:1354)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readHierarchy(ObjectInputStream.java:1266)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readNewObject(ObjectInputStream.java:1851)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readNonPrimitiveContent(ObjectInputStream.java:787)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1999)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:1956)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at com.vittorio.floaty.AcceptThread.run(AcceptThread.java:80)
07-03 07:52:34.409: E/AndroidRuntime(1600):     at java.lang.Thread.run(Thread.java:856)

这怎么可能发生?我的意思是索引太大了,没有多大意义。无论如何,我正在交换一个包含 ArrayList 的序列化对象。

4

0 回答 0