I use the OpenOffice API from my Java Program to handle Documents for me. Sometimes (once every 100k or so calls) the dispose method of a Document does not return, the CPU load stays at 100% but nothing seems to happen.
How should I act / code correctly in this situation?
My current approach is to wait for the dispose to succeed for two seconds. If it does not I try to terminate OpenOffice through the appropriate API. If that fails as well (as I would expect) then I kill the soffice process with a call to
XDesktop xDesk = (...) // achive desktop
xDesk.terminate();
Runtime.getRuntime().exec("pkill soffice"); // "taskkill /IM soffice" on windows
and then call
disposeThread.stop();
to the Thread that initially tries to dispose the XComponent. Now the Java API says that Thread.stop()
should not be used (and there are valid arguments to that) so I'm wondering if there are any better solutions that what I did.