Forums Register Login

java.io.IOException: Bad file descriptor

+Pie Number of slices to send: Send
I am using JBuilder to develop my SCJD project.
And I add finalize method in Data.java to close RandomAccessFile object.
However, when I test my code by using JUnit in JBuilder, the finalize mehtod is called to close
db file before some test methods in my JUnit code. So it always gives me :

java.io.IOException: Bad file descriptor

Dose anyone know how to prevent from calling finalize method before running JUnit Code???
Thanks.
+Pie Number of slices to send: Send
Finalize is called when the garbage collector is about to reclaim the memory. So you JUnit class must still be going, after you already set the object to null, or it went out of scope. The garbage collector works when it wants to, so you really can't time something like that. You can keep the instance going in your JUnit till that ends, then you won't have that problem.

Mark
+Pie Number of slices to send: Send
Dear Mark.

Thank you for the reply.
I gave up the finalize method but keep shutdown hook.
This guy is skipping without a rope. At least, that's what this tiny ad said:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 2068 times.
Similar Threads
About RandomAccessFile
RandomAccessFile.read(): Bad file descriptor ?
Problem reading file: Bad file descriptor
why does JUnit build every time?
NX: IOException: Bad file descriptor
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 04:24:13.