Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Commit

Permalink
[FIXED JENKINS-15613] Define XML parser property so that Xerces is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 13, 2013
1 parent e113d86 commit 00eb7ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -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>

Expand Down
Expand Up @@ -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;

Expand All @@ -33,7 +34,10 @@ public class DuplicationParserRegistry implements AnnotationParser {
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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -97,6 +106,9 @@ public Collection<FileAnnotation> parse(final File file, final String moduleName
}
finally {
IOUtils.closeQuietly(inputStream);
if (oldProperty != null) {
System.setProperty(SAX_DRIVER_PROPERTY, oldProperty);
}
}
}

Expand Down

0 comments on commit 00eb7ca

Please sign in to comment.