InitializationException eats exception of constructor called by @XStreamConverter #37

Closed
ge0ffrey opened this Issue Jan 21, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@ge0ffrey

We have code like this (in optaplanner.org):

public class CloudBalance {

    @XStreamConverter(value = XStreamScoreConverter.class, types = {HardSoftScoreDefinition.class})
    private HardSoftScore score;

}

public class XStreamScoreConverter {

    public XStreamScoreConverter(Class scoreClass, Class scoreDefinitionClass) {
        if (scoreDefinitionClass.equals(HardSoftScoreDefinition.class)) { // true
            throw new IllegalStateException("Please don't eat me!!!");
        }
    }
}

And that throws this exception:

com.thoughtworks.xstream.InitializationException: Cannot instantiate converter ...XStreamScoreConverter for type ...HardSoftScore : Cannot construct ...XStreamScoreConverter : null

Notice that the IllegalStateException "Please don't eat me!!!" is actually eaten. Instead of being eaten, it should be wrapped as a cause:

Caused by: ...IllegalStateException Please don't eat me!!!

@joehni joehni added the bug label Feb 9, 2016

@joehni joehni added this to the 1.4.x milestone Feb 9, 2016

@joehni joehni self-assigned this Feb 9, 2016

@joehni

This comment has been minimized.

Show comment
Hide comment
@joehni

joehni Feb 9, 2016

Member

Caused by JDK 1.3 compatibility code ;-)

Member

joehni commented Feb 9, 2016

Caused by JDK 1.3 compatibility code ;-)

joehni added a commit that referenced this issue Feb 9, 2016

@joehni joehni closed this in e2f0a64 Feb 9, 2016

@ge0ffrey

This comment has been minimized.

Show comment
Hide comment
@ge0ffrey

ge0ffrey Feb 9, 2016

Thanks, xstream is great :)

ge0ffrey commented Feb 9, 2016

Thanks, xstream is great :)

@joehni joehni modified the milestones: 1.4.9, 1.4.x Mar 16, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment