Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-65161] remove commons-digester2 from core and upgrade plugins to commons-digester3 #20

Merged
merged 4 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ com.ibm.team.build.hjplugin/.classpath
com.ibm.team.build.hjplugin/.jazzignore
com.ibm.team.build.hjplugin/.project
com.ibm.team.build.hjplugin/build.properties
*.iml
6 changes: 5 additions & 1 deletion com.ibm.team.build.hjplugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,17 @@
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.ibm.team.build</groupId>
<artifactId>com.ibm.team.build.hjplugin-rtc</artifactId>
<version>${rtcJarVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-digester3</artifactId>
<version>3.2</version>
</dependency>
<dependency>
<groupId>com.ibm.team.build</groupId>
<artifactId>com.ibm.team.build.hjplugin-rtc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import hudson.scm.RepositoryBrowser;
import hudson.scm.ChangeLogSet;
import hudson.scm.ChangeLogSet.Entry;
import hudson.util.Digester2;

import java.io.File;
import java.io.FileInputStream;
Expand All @@ -29,8 +28,11 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import org.apache.commons.digester3.Digester;
import org.xml.sax.SAXException;

import javax.xml.parsers.ParserConfigurationException;

public class RTCChangeLogParser extends ChangeLogParser {
private static final Logger LOGGER = Logger.getLogger(RTCChangeLogParser.class.getName());

Expand Down Expand Up @@ -59,7 +61,7 @@ public ChangeLogSet<? extends Entry> parse(Run build, RepositoryBrowser<?> brows
LOGGER.finest("RTCChangeLogParser.parse with Reader : Begin"); //$NON-NLS$1
try {
RTCChangeLogSet result = new RTCChangeLogSet(build, browser);
Digester2 digester = getDigester();
Digester digester = getDigester();
digester.push(result);

digester.addSetProperties("changelog"); //$NON-NLS-1$
Expand Down Expand Up @@ -133,12 +135,11 @@ public ChangeLogSet<? extends Entry> parse(Run build, RepositoryBrowser<?> brows
}
}

private Digester2 getDigester() {
private Digester getDigester() throws SAXException {
LOGGER.finest("RTCChangeLogParser.getDigester : Begin");
Digester2 digester;
Digester digester;
try {
digester = new Digester2();
return digester;
digester = new Digester();
} catch (Error e) {
LOGGER.log(Level.FINER, "Failed to get Digest2 error: " + e.getMessage(), e);
dumpClassLoader("getDigester()");
Expand All @@ -147,12 +148,25 @@ private Digester2 getDigester() {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader());
digester = new Digester2();
return digester;
digester = new Digester();
} finally {
Thread.currentThread().setContextClassLoader(classLoader);
}
}
digester.setXIncludeAware(false);

if (!Boolean.getBoolean(RTCChangeLogParser.class.getName() + ".UNSAFE")) {
try {
digester.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
digester.setFeature("http://xml.org/sax/features/external-general-entities", false);
digester.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
digester.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
}
catch ( ParserConfigurationException ex) {
throw new SAXException("Failed to securely configure RTC changelog parser", ex);
}
}
return digester;
}

private void dumpClassLoader(String string) {
Expand Down