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

Commit

Permalink
[FIXED JENKINS-27548] Do not alter SAX environment variable anymore.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Feb 27, 2016
1 parent fb09c94 commit e5aa4fb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 62 deletions.
4 changes: 2 additions & 2 deletions plugin/findbugs.iml
Expand Up @@ -24,6 +24,8 @@
<orderEntry type="library" name="Maven: org.jvnet.hudson.plugins:analysis-core:1.75" level="project" />
<orderEntry type="library" name="Maven: de.java2html:java2html:5.0" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.3.2" level="project" />
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jvnet.hudson.plugins:analysis-test:1.18" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jenkins-ci.plugins.workflow:workflow-job:1.5" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jenkins-ci.plugins.workflow:workflow-support:1.5" level="project" />
Expand Down Expand Up @@ -54,8 +56,6 @@
<orderEntry type="library" name="Maven: asm:asm:3.3.1" level="project" />
<orderEntry type="library" name="Maven: commons-beanutils:commons-beanutils:1.8.3" level="project" />
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.1.1" level="project" />
<orderEntry type="library" name="Maven: xerces:xercesImpl:2.11.0" level="project" />
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.4.01" level="project" />
<orderEntry type="library" name="Maven: org.jenkins-ci.plugins:matrix-project:1.2.1" level="project" />
<orderEntry type="library" name="Maven: org.jenkins-ci.plugins:script-security:1.13" level="project" />
<orderEntry type="library" name="Maven: org.kohsuke:groovy-sandbox:1.8" level="project" />
Expand Down
5 changes: 0 additions & 5 deletions plugin/pom.xml
Expand Up @@ -64,11 +64,6 @@
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>

<scm>
Expand Down
Expand Up @@ -17,8 +17,6 @@

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

import hudson.plugins.analysis.util.SaxSetup;

/**
* Parses the FindBugs pattern descriptions and provides access to these HTML messages.
*
Expand All @@ -39,19 +37,15 @@ private static class FindBugsMessagesHolder {
}

private static FindBugsMessages initializeSingleton() {
FindBugsMessages res = new FindBugsMessages();
SaxSetup sax = new SaxSetup();
FindBugsMessages messages = new FindBugsMessages();
try {
res.initialize();
messages.initialize();
}
catch (Exception exception) {
Logger.getLogger(FindBugsMessages.class.getName()).log(Level.WARNING,
"FindBugsMessages initializeSingleton failed", exception);
}
finally {
sax.cleanup();
}
return res;
return messages;
}

/**
Expand Down
Expand Up @@ -36,7 +36,6 @@
import edu.umd.cs.findbugs.cloud.Cloud;

import hudson.plugins.analysis.core.AnnotationParser;
import hudson.plugins.analysis.util.SaxSetup;
import hudson.plugins.analysis.util.TreeStringBuilder;
import hudson.plugins.analysis.util.model.FileAnnotation;
import hudson.plugins.analysis.util.model.LineRange;
Expand Down Expand Up @@ -363,7 +362,6 @@ private Priority getPriority(final BugInstance warning) {
}

private SortedBugCollection readXml(final InputStream file) throws IOException, DocumentException {
SaxSetup sax = new SaxSetup();
ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(FindBugsParser.class.getClassLoader());
Expand All @@ -373,7 +371,6 @@ private SortedBugCollection readXml(final InputStream file) throws IOException,
}
finally {
Thread.currentThread().setContextClassLoader(contextClassLoader);
sax.cleanup();
}
}

Expand Down
Expand Up @@ -2,7 +2,14 @@

import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.commons.io.IOUtils;
import org.dom4j.DocumentException;
Expand All @@ -12,8 +19,11 @@
import static org.junit.Assert.*;

import hudson.plugins.analysis.test.AbstractEnglishLocaleTest;
import hudson.plugins.analysis.util.SaxSetup;
import hudson.plugins.analysis.util.model.*;
import hudson.plugins.analysis.util.model.FileAnnotation;
import hudson.plugins.analysis.util.model.JavaPackage;
import hudson.plugins.analysis.util.model.LineRange;
import hudson.plugins.analysis.util.model.MavenModule;
import hudson.plugins.analysis.util.model.Priority;
import hudson.plugins.findbugs.Messages;

/**
Expand Down Expand Up @@ -142,46 +152,6 @@ public void issue12314() throws IOException, SAXException, DocumentException {
60, 60, 1);
}

/**
* Checks that the SAX property is overwritten with Xerces if it has been set to another value.
*
* @throws IOException
* in case of an error
* @throws SAXException
* in case of an error
* @throws DocumentException
* in case of an error
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-7312">Issue 7312</a>
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-7932">Issue 7932</a>
*/
@Test
public void issue7312and7932() throws IOException, SAXException, DocumentException {
String saxParser = this.getClass().getName();
System.setProperty(SaxSetup.SAX_DRIVER_PROPERTY, saxParser);
MavenModule module = parseFile("issue7312.xml", false);
assertEquals("Wrong number of warnings", 0, module.getNumberOfAnnotations());
assertEquals("Wrong sax parser property", saxParser, System.getProperty(SaxSetup.SAX_DRIVER_PROPERTY));
}

/**
* Checks that the SAX property is not touched if it is null.
*
* @throws IOException
* in case of an error
* @throws SAXException
* in case of an error
* @throws DocumentException
* in case of an error
* @see <a href="http://issues.jenkins-ci.org/browse/JENKINS-7932">Issue 7932</a>
*/
@Test
public void issue7932Null() throws IOException, SAXException, DocumentException {
System.clearProperty(SaxSetup.SAX_DRIVER_PROPERTY);
MavenModule module = parseFile("issue7312.xml", false);
assertEquals("Wrong number of warnings", 0, module.getNumberOfAnnotations());
assertNull("Wrong sax parser property", System.getProperty(SaxSetup.SAX_DRIVER_PROPERTY));
}

/**
* Tests the message mapping.
*
Expand Down

0 comments on commit e5aa4fb

Please sign in to comment.