Uploaded image for project: 'JBoss Web Services'
  1. JBoss Web Services
  2. JBWS-2686

Parsing errors fail to terminate unmarshalling

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Major
    • None
    • jbossws-native-3.1.2
    • jbossws-native
    • None

    Description

      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();

      Attachments

        Issue Links

          Activity

            People

              ropalka Richard Opalka
              darran.lofthouse@redhat.com Darran Lofthouse
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: