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

Commit

Permalink
[ FIXED JENKINS-20070] Clear SAX system property afterwards.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 30, 2014
1 parent d53abb1 commit 50667ef
Showing 1 changed file with 3 additions and 11 deletions.
Expand Up @@ -9,6 +9,7 @@
import java.util.List;
import java.util.Set;

import hudson.plugins.analysis.util.SaxSetup;
import org.apache.commons.io.IOUtils;
import org.apache.xerces.parsers.SAXParser;

Expand Down Expand Up @@ -36,9 +37,6 @@ 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}.
*
Expand Down Expand Up @@ -77,11 +75,7 @@ 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());
}

SaxSetup sax = new SaxSetup();
FileInputStream inputStream = null;
try {
for (AbstractDryParser parser : parsers) {
Expand Down Expand Up @@ -112,10 +106,8 @@ public Collection<FileAnnotation> parse(final File file, final String moduleName
throw new InvocationTargetException(exception);
}
finally {
sax.cleanup();
IOUtils.closeQuietly(inputStream);
if (oldProperty != null) {
System.setProperty(SAX_DRIVER_PROPERTY, oldProperty);
}
}
}

Expand Down

0 comments on commit 50667ef

Please sign in to comment.