Issue Details (XML | Word | Printable)

Key: WSTX-110
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Tatu Saloranta
Reporter: Erik Bergersjo
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Woodstox

IllegalStateException on JDK 1.5 (easy to fix)

Created: 10/Mar/07 04:54 AM   Updated: 05/Jun/07 08:45 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

Environment: J2SE 1.5, Windows XP


 Description  « Hide
On network problems Freecol complains about an IllegalStateException in the receiving thread. See stack trace below. Apparently the Woodstox library does not support JDK 1.5. The Jdk14Impl class calls a method that fails on JDK 1.5 and the WstxIOException is converted into an IllegalStateException (loosing any
useful information in the process).

This is easy to fix. Simply catch the exception in Jdk14Impl.setInitCause:

public boolean setInitCause(Throwable newT, Throwable rootT) {
try { newT.initCause(rootT); } catch(IllegalStateException e) { // This happens on JDK 1.5, ignore }
return true;
}

An alternative is of course to add explicit support for JDK 1.5 and 1.6.

----------------
Exception in thread "ReceivingThread" java.lang.IllegalStateException:
Can't overwrite cause
at java.lang.Throwable.initCause(Throwable.java:320)
at com.ctc.wstx.compat.Jdk14Impl.setInitCause(Jdk14Impl.java:70)
at com.ctc.wstx.exc.WstxException.<init>(WstxException.java:46)
at com.ctc.wstx.exc.WstxIOException.<init>(WstxIOException.java:16)
at
com.ctc.wstx.stax.WstxInputFactory.doCreateSR(WstxInputFactory.java:536)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:589)
at com.ctc.wstx.stax.WstxInputFactory.createSR(WstxInputFactory.java:604)
at
com.ctc.wstx.stax.WstxInputFactory.createXMLStreamReader(WstxInputFactory.j
ava:305)
at
net.sf.freecol.common.networking.ReceivingThread.listen(ReceivingThread.jav
a:193)
at
net.sf.freecol.common.networking.ReceivingThread.run(ReceivingThread.java:1
22)



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Tatu Saloranta added a comment - 15/Mar/07 12:43 AM
Hmmh. Interesting.

As to JDK 1.5 support: actually, it is fully supported. 1.5 is the main development platform. But I have never seen this particular problem before. It should be easy to fix: but I'd prefer not trying to catch an exception, but rather prevent it from occuring. It's not quite clear where an already chained exception is being relinked, perhaps it's just a simple mixup with arguments.

Anyway, I'll definitely resolve this one way or another.


Tatu Saloranta added a comment - 15/Mar/07 01:10 AM
Actually, I think I can guess what is going on here: implementation of XMLStreamException in Stax API may differ for Java 5 and 6, such that it will actually initialize root exception properly.

At any rate, I'll add check to init cause adding method, to first see if there is already an init cause, and only try to set it, if not.


Tatu Saloranta added a comment - 15/Mar/07 01:22 AM
Fixed in 3.2 branch (for 3.2.1 release), trunk (4.0). Will need more Jira access to resolve this entry.

Erik Bergersjo added a comment - 15/Mar/07 02:24 AM
Excellent. I don't seem to be able to set it as resolved either, but it sounds like a much better solution than mine. I will verify that it works and add the new code to Freecol this weekend.

Tatu Saloranta added a comment - 22/Mar/07 12:17 AM
Cool. Let me know if you still have problems – for now, I'll resolve this entry.

Tatu Saloranta added a comment - 05/Jun/07 08:45 PM
Fixed also on 3.0 and 3.1 branches, in addition to 3.2.1 and trunk (4.0)