Menu

#147 Custom ModelClassFactory not set in XMLParser constructor

closed-fixed
Parser (9)
5
2012-06-11
2012-05-30
No

in XMLParser, the contructor doesn't use the 'theFactory' parameter anywhere to set the 'myFactory' member in the parent Parser. The constructor should probably call super(theFactory). As a result, custom messages parsed using XML encoding may get a java.lang.ClassCastException: ca.uhn.hl7v2.model.GenericMessage$V25 (or similar for other versions) if they try to cast the result to their custom message type.

public XMLParser(ModelClassFactory theFactory) {
parser = new DOMParser(new StandardParserConfiguration());
try {
parser.setFeature("http://apache.org/xml/features/dom/include-ignorable-whitespace", false);
}
catch (Exception e) {
log.error("Can't exclude whitespace from XML DOM", e);
}
}

Discussion

  • Christian Ohr

    Christian Ohr - 2012-06-11
    • assigned_to: nobody --> ohr
    • status: open --> closed-fixed
     
  • Stephen Doxsee

    Stephen Doxsee - 2012-06-12

    Thanks for fixing this Christian! I saw the change on the 2.0beta1. Is it possible to apply this to earlier releases (i.e. 1.2) as well (or does that defeat the purpose of a "release")?...I haven't seen any "SNAPSHOT" versions.
    Thanks!
    Stephen

     
  • Christian Ohr

    Christian Ohr - 2012-06-13

    We usually try to be backwards-compatible with new versions so there shuold be not a major problem to switch to 2.0 once it's released.

     
  • Nobody/Anonymous

    Excellent! Thanks.

     

Log in to post a comment.