Woodstox

IllegalStateException on JDK 1.5 (easy to fix)

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    J2SE 1.5, Windows XP
  • Number of attachments :
    0

Description

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)

Activity

Hide
Tatu Saloranta added a comment -

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.

Show
Tatu Saloranta added a comment - 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.
Hide
Tatu Saloranta added a comment -

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.

Show
Tatu Saloranta added a comment - 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.
Hide
Tatu Saloranta added a comment -

Fixed in 3.2 branch (for 3.2.1 release), trunk (4.0). Will need more Jira access to resolve this entry.

Show
Tatu Saloranta added a comment - Fixed in 3.2 branch (for 3.2.1 release), trunk (4.0). Will need more Jira access to resolve this entry.
Hide
Erik Bergersjo added a comment -

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.

Show
Erik Bergersjo added a comment - 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.
Hide
Tatu Saloranta added a comment -

Cool. Let me know if you still have problems – for now, I'll resolve this entry.

Show
Tatu Saloranta added a comment - Cool. Let me know if you still have problems – for now, I'll resolve this entry.
Hide
Tatu Saloranta added a comment -

Fixed also on 3.0 and 3.1 branches, in addition to 3.2.1 and trunk (4.0)

Show
Tatu Saloranta added a comment - Fixed also on 3.0 and 3.1 branches, in addition to 3.2.1 and trunk (4.0)

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: