.lang.IllegalStateException: unread block data

Hello,

I'm having a very strange problem with little program I'm developing.

-- CODE --

ObjectInputStream is = new ObjectInputStream(new FileInputStream(file));

memory_test = (MemoryTestData)is.readObject();

is.close();

-

At the runtime I'm getting a 'java.lang.IllegalStateException: unread block data' at the readObject(), and the strange thing is that this only happens when I try to open the same one file (it only happens with one of my files) two consecutive times. If I open one other file in between I don't get any error, neither when I open any other file two or more consecutive times.... It only happens with a file which has 34.4Mb, all my other files are considerably smaller as they were only for testing purpose.

Does anyone have an idea of what might be happening?

Here's the Stack Trace (Long):

java.lang.IllegalStateException: unread block data

at java.io.ObjectInputStream$BlockDataInputStream.setBlockDataMode(ObjectInputStream.java:2264)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1305)

at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)

at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)

at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)

at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)

at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)

at PacientMemoryJDialog.choose_teste_jButtonActionPerformed(PacientMemoryJDialog.java:385)

at PacientMemoryJDialog.access$200(PacientMemoryJDialog.java:7)

at PacientMemoryJDialog$3.actionPerformed(PacientMemoryJDialog.java:168)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)

at java.awt.Component.processMouseEvent(Component.java:5093)

at java.awt.Component.processEvent(Component.java:4890)

at java.awt.Container.processEvent(Container.java:1566)

at java.awt.Component.dispatchEventImpl(Component.java:3598)

at java.awt.Container.dispatchEventImpl(Container.java:1623)

at java.awt.Component.dispatchEvent(Component.java:3439)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)

at java.awt.Container.dispatchEventImpl(Container.java:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1585)

at java.awt.Component.dispatchEvent(Component.java:3439)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:140)

at java.awt.Dialog.show(Dialog.java:538)

at PacientMemoryJDialog.<init>(PacientMemoryJDialog.java:27)

at VisualTests.run_image_jMenuItemActionPerformed(VisualTests.java:263)

at VisualTests.access$100(VisualTests.java:4)

at VisualTests$2.actionPerformed(VisualTests.java:60)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)

at javax.swing.AbstractButton.doClick(AbstractButton.java:289)

at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1109)

at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(BasicMenuItemUI.java:943)

at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:227)

at java.awt.Component.processMouseEvent(Component.java:5093)

at java.awt.Component.processEvent(Component.java:4890)

at java.awt.Container.processEvent(Container.java:1566)

at java.awt.Component.dispatchEventImpl(Component.java:3598)

at java.awt.Container.dispatchEventImpl(Container.java:1623)

at java.awt.Component.dispatchEvent(Component.java:3439)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)

at java.awt.Container.dispatchEventImpl(Container.java:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1585)

at java.awt.Component.dispatchEvent(Component.java:3439)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

Thank you for your time

[5671 byte] By [TomaHawKa] at [2007-9-28 13:26:25]
# 1

I've had a similar problem recently. I'm not sure if the bug is completely gone, but I think it had something to do with the input stream being closed at the "sending" end before the receiving end has finished reading the file. The reason it might only be happening for big files is that small files might be able to slip through before the input stream changes to a new file, whereas the larger file might not yet have been read. The input stream indicates that it is closing/changing while the input is being read and this throws an exception (block data is still unread). However, I had this problem while using sockets, etc, etc so it might not be the same thing. I see you posted this problem a while ago so you might have already solved it or worked around it. If you have solved it, would you let me know because I might get the same problem again and my "solution" might not work twice.

Thanks

Adam

Mr_Wilsona at 2007-7-12 9:26:09 > top of Java-index,Developer Tools,Debugging and Profiling Tool APIs...