Hi,
I upgraded from 1.1-M4 to 1.1-M5 and found many of my Unit Tests that depend on
the JaxbRepresentation breaking. I traced the code to the following line where
the Marshaller is being created:
m.setProperty("jaxb.encoding", getCharacterSet().getName());
The CharacterSet is null and thus an NPE gets thrown. The parent class, i.e.,
Variant's character set has not been set.
If I change the code to the following:
JaxbRepresentation rep = new JaxbRepresentation(MediaType.APPLICATION_XML,
someObject);
rep.setCharacterSet(CharacterSet.UTF_8);
then the code works fine.
Is the direction moving forward to specifically provide a CharacterSet when
creating representations? Until now, the default CharacterSet used by Jaxb
internally was sufficient us for most cases with having
to provide a Character set specifically only in some edge cases (a welcomed
enhancement). With the above introduction, setting the CharacterSet on every
JaxbRepresentation is mandated.
Would it make sense to change the above code to be:
if (getCharacterSet() != null) {
m.setProperty("jaxb.encoding", getCharacterSet().getName());
}
thus if no character set is provided use the default character set?
or have the JaxbRepresentation constructors default to a CharacterSet?
I might be missing the Restlet CharacterSet philosophy and direction.
Thanks much in advance,
Sanjay
_________________________________________________________________
See what people are saying about Windows Live. Check out featured posts.
http://www.windowslive.com/connect?ocid=TXT_TAGLM_WL_connect2_082008