[jbossws-issues] [JBoss JIRA] Created: (JBWS-2686) Parsing errors fail to terminate unmarshalling

Darran Lofthouse (JIRA) jira-events at lists.jboss.org
Thu Jun 18 11:56:56 EDT 2009


Parsing errors fail to terminate unmarshalling
----------------------------------------------

                 Key: JBWS-2686
                 URL: https://jira.jboss.org/jira/browse/JBWS-2686
             Project: JBoss Web Services
          Issue Type: Bug
      Security Level: Public (Everyone can see)
          Components: jbossws-native
    Affects Versions:  jbossws-native-3.1.2
            Reporter: Darran Lofthouse
            Assignee: Alessio Soldano
             Fix For: jbossws-native-3.2.0


If a message received suffers an error converting a value the error is silently dropped and the field is left initialised with the default value.

i.e. if an NumberFormatExceptions are thrown converting Strings to longs then the NumberFormatException is dropped and the field left to the default value.

The Unmarshaller should by default terminate for the first error or fatal error, currently it only terminates for a fatal error: -

http://java.sun.com/javaee/5/docs/api/javax/xml/bind/Unmarshaller.html#setEventHandler%28javax.xml.bind.ValidationEventHandler%29

This is a JAXB issue as raised here: -
  https://jaxb.dev.java.net/issues/show_bug.cgi?id=655

A workaround could be to add a ValidationEventHandler with this behaviour to our JAXBDeserializer: -

         Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
         unmarshaller.setAttachmentUnmarshaller( new AttachmentUnmarshallerImpl());
         unmarshaller.setEventHandler(new ValidationEventHandler() {

            public boolean handleEvent(final ValidationEvent event)
            {
               int severity = event.getSeverity();
               return (severity != ValidationEvent.FATAL_ERROR && severity != ValidationEvent.ERROR);
            }

         });
         
         JAXBElement jbe = unmarshaller.unmarshal(xmlFragment, javaType);
         value = jbe.getValue();


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the jbossws-issues mailing list