Skip to content
Permalink
Browse files
[FIXED JENKINS-15613] Define XML parser property so that Xerces is used.
  • Loading branch information
uhafner committed Feb 13, 2013
1 parent e113d86 commit 00eb7ca09654acd080f85381ce606197b2f8dc5b
Showing with 14 additions and 2 deletions.
  1. +1 −1 pom.xml
  2. +13 −1 src/main/java/hudson/plugins/dry/parser/DuplicationParserRegistry.java
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<artifactId>analysis-pom</artifactId>
<version>1.40</version>
<version>1.42</version>
<relativePath>../analysis-pom/pom.xml</relativePath>
</parent>

@@ -16,6 +16,7 @@
import java.util.Set;

import org.apache.commons.io.IOUtils;
import org.apache.xerces.parsers.SAXParser;

import com.google.common.collect.Sets;

@@ -33,7 +34,10 @@
private String workspacePath;
private final String defaultEncoding;

/**
/** Property of SAX parser factory. */
private static final String SAX_DRIVER_PROPERTY = "org.xml.sax.driver";

/**
* Creates a new instance of {@link DuplicationParserRegistry}.
*
* @param highThreshold
@@ -70,6 +74,11 @@ public DuplicationParserRegistry(final int normalThreshold, final int highThresh

/** {@inheritDoc} */
public Collection<FileAnnotation> parse(final File file, final String moduleName) throws InvocationTargetException {
String oldProperty = System.getProperty(SAX_DRIVER_PROPERTY);
if (oldProperty != null) {
System.setProperty(SAX_DRIVER_PROPERTY, SAXParser.class.getName());
}

FileInputStream inputStream = null;
try {
for (AbstractDryParser parser : parsers) {
@@ -97,6 +106,9 @@ public DuplicationParserRegistry(final int normalThreshold, final int highThresh
}
finally {
IOUtils.closeQuietly(inputStream);
if (oldProperty != null) {
System.setProperty(SAX_DRIVER_PROPERTY, oldProperty);
}
}
}

0 comments on commit 00eb7ca

Please sign in to comment.