Parse Xml Netconf msgs without defer-node-expansion option 79/18579/1
authorMaros Marsalek <mmarsale@cisco.com>
Fri, 17 Apr 2015 11:46:21 +0000 (13:46 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Sat, 18 Apr 2015 12:58:50 +0000 (14:58 +0200)
The defer-node-expansion expands inner nodes on traversal, but its suitable for
bigger xmls (100k bytes) and messages that are not fully traversed. This is not
the case with incomming netconf rpc.

Source:
https://xerces.apache.org/xerces2-j/faq-performance.html

Tested:
Netconf server pipeline performance was improved by 5-6%

Change-Id: I3bd4b917841f0ebe212ff753d6e0f655d618968c
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
opendaylight/netconf/netconf-util/src/main/java/org/opendaylight/controller/netconf/util/xml/XmlUtil.java

index 4ae65f31f72a6240e92d85be49e07c4f70b3115d..6408fce5d39b199c1105807619bf9e4e0198c4f6 100644 (file)
@@ -55,6 +55,9 @@ public final class XmlUtil {
             factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
             factory.setXIncludeAware(false);
             factory.setExpandEntityReferences(false);
             factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
             factory.setXIncludeAware(false);
             factory.setExpandEntityReferences(false);
+            // Performance improvement for messages with size <10k according to
+            // https://xerces.apache.org/xerces2-j/faq-performance.html
+            factory.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
         } catch (ParserConfigurationException e) {
             throw new ExceptionInInitializerError(e);
         }
         } catch (ParserConfigurationException e) {
             throw new ExceptionInInitializerError(e);
         }