Hi Oscar,

Oscar Picasso wrote:

> Hi,
> 
> I am interested to know if there is an idiomatic way to avoid or recover
> from crashes in the following use case.
> 
> The program opens an OpenOffice writer document with a custom XInputStream
> defined below.
> It changes some user fields and bookmarks contents and save the document as
> pdf.
> 
> For saving it uses the XStorable.storeUrl method and a custom XOutputStream,
> also defined below.
> 
> When doing the stress test below, it always crashes after having looped
> around 8500 times with the exception:
> com.sun.star.lang.IllegalArgumentException: URL seems to be an unsupported
> one
> 
> I have put a comment on the code above the line where the program itself
> crashes.

First of all: what you have found is not a crash, because:

> The OpenOffice instance is still up and running though.
> 
> 1- Is there something wrong in the code that causes the crash? Maybe some
> wrong parameter?
> Something else that needs to be closed or disposed?
> 
> 2- If not is there a proper way to recover from the crash and retry the
> operation?
> What are usually the recoverable exceptions and which cleanup should be
> done? Maybe we need to reload / refresh / recreate some object for a safe
> recovery?
> 
> Any idea?
> 
> PS.: I find the "URL seems to be an unsupported one" message quite puzzling
> since the URL that is used is always "private:stream".
> So why do this URL become unsupported after it has been used for about 8500
> times?

If a "private:stream" URL is detected, OOo tries to retrieve the
InputStream from the MediaDescriptor. Only if this fails the
"Unsupported" Exception is thrown. The same may happen if no known
content type can be detected from the stream. I can't see how this could
happen in your code as you seem to use the same file all the time.

You could retry the failed call with the same arguments and this time
debug the code in OOo to see why it failed. You will need to have the
framework libraries and the filterconfig library (in module filter) with
debug information.

BTW: you shouldn't close the document by calling dispose(), please use
close(True) instead. But be prepared to catch CloseVetoExceptions then.
In case you get such exceptions that could be a sign that OOo can't
close the loaded document and perhaps has a resource problem. Maybe
either your application or OOo runs out of file handles?!

Regards,
Mathias

-- 
Mathias Bauer (mba) - Project Lead OpenOffice.org Writer
OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS
Please don't reply to "[email protected]".
I use it for the OOo lists and only rarely read other mails sent to it.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to