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

Upgrade dom4j from 1.6.1 to 2.1.3 #9939

Merged
merged 2 commits into from
Dec 17, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
*/


import com.github.jk1.license.task.ReportTask
import com.github.jk1.license.filter.LicenseBundleNormalizer
import com.github.jk1.license.render.JsonReportRenderer
import com.github.jk1.license.task.ReportTask
import groovy.io.FileType
import nl.javadude.gradle.plugins.license.License
import org.apache.tools.ant.filters.FixCrLfFilter
Expand Down Expand Up @@ -647,6 +647,7 @@ subprojects {
}

project.configurations*.exclude(group: 'junit')
project.configurations*.exclude(group: 'dom4j')
project.configurations*.exclude(group: 'xalan')
project.configurations*.exclude(group: 'xml-apis')
}
Expand Down
5 changes: 4 additions & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ dependencies {
api project(':util')
api project(':domain')
api project(':plugin-infra:go-plugin-access')
api project.deps.dom4j
api(project.deps.dom4j) {
// workaround for dom4j Gradle metadata optional dependency issues (https://github.com/dom4j/dom4j/issues/99)
transitive = false
}
api project.deps.apacheHttpMime
api project.deps.commonsCollections4
api project.deps.commonsText
Expand Down
1 change: 1 addition & 0 deletions config/config-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dependencies {
}
implementation project.deps.slf4j
implementation project.deps.cglib
implementation project.deps.jaxen
compileOnly project.deps.jetBrainsAnnotations
providedAtPackageTime(project.deps.bouncyCastle)
testImplementation project(path: ':config:config-api', configuration: 'testOutput')
Expand Down
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ final Map<String, String> libraries = [
commonsPool : 'org.apache.commons:commons-pool2:2.11.1',
commonsText : 'org.apache.commons:commons-text:1.9',
dbunit : 'org.dbunit:dbunit:2.7.2',
dom4j : 'dom4j:dom4j:1.6.1',
dom4j : 'org.dom4j:dom4j:2.1.3',
ehcache : 'net.sf.ehcache:ehcache:2.10.9.2',
felix : 'org.apache.felix:org.apache.felix.framework:7.0.3',
freemarker : 'org.freemarker:freemarker:2.3.31',
Expand Down
18 changes: 0 additions & 18 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,6 @@ dependencies {
implementation project.deps.mailSmtp
implementation project.deps.objenesis

// needed by jdom2 for some XPATH stuff
implementation(project.deps.jaxen) {
exclude(module: 'xom')
exclude(module: 'jdom')
}
implementation project.deps.slf4j
implementation(project.deps.jgitServer) {
exclude(module: 'jsch')
Expand Down Expand Up @@ -969,19 +964,6 @@ task licenseReportAggregate {
]
]
],
[
moduleName : 'dom4j:dom4j',
moduleVersion : '1.6.1',
moduleUrls : [
"https://dom4j.github.io/"
],
moduleLicenses: [
[
moduleLicense : 'dom4j BSD license',
moduleLicenseUrl: "https://github.com/dom4j/dom4j/blob/dom4j_1_6_1/LICENSE.txt"
]
]
],
[
moduleName : 'com.bazaarvoice.jolt:jolt-core',
moduleVersion : project.versions.jolt,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private void addEntry(StageFeedEntry feed, ElementBuilder builder, XmlWriterCont
.textNode("id", entryUrl);

if (feed.isManuallyTriggered()) {
builder.node("go:author", childBuilder -> childBuilder.cdataNode("go:name", feed.getApprovedBy()));
builder.node("go", "author", childBuilder -> childBuilder.cdataNode("go", "name", feed.getApprovedBy()));
}

feed.getAuthors().forEach(author -> {
Expand All @@ -82,7 +82,7 @@ private void addEntry(StageFeedEntry feed, ElementBuilder builder, XmlWriterCont
});

if (isNotBlank(feed.getCancelledBy())) {
builder.node("cancelledBy", child -> child.cdataNode("go:name", feed.getCancelledBy()));
builder.node("cancelledBy", child -> child.cdataNode("go", "name", feed.getCancelledBy()));
}

String stageTitle = identifier.getStageName() + " Stage Detail";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,20 @@ public SELF cdataNode(String name, String CDATA) {
return mySelf;
}

public SELF cdataNode(String prefix, String name, String CDATA) {
current().add(withNamespace(prefix, name).addCDATA(CDATA));
return mySelf;
}

public SELF link(String href, String rel) {
current().add(getLink(href, rel));
return mySelf;
}

public SELF link(String href, String rel, String title, String type) {
current().add(getLink(href, rel)
.addAttribute("title", title)
.addAttribute("type", type));
.addAttribute("title", title)
.addAttribute("type", type));
return mySelf;
}

Expand All @@ -69,6 +74,13 @@ public SELF node(String name, Consumer<ElementBuilder> consumer) {
return mySelf;
}

public SELF node(String prefix, String name, Consumer<ElementBuilder> consumer) {
DOMElement element = withNamespace(prefix, name);
current().add(element);
consumer.accept(new ElementBuilder(element));
return mySelf;
}

public SELF emptyNode(String name) {
DOMElement element = withNamespace(name);
current().add(element);
Expand All @@ -95,8 +107,8 @@ public SELF comment(String comment) {

private Element getLink(String href, String rel) {
return withNamespace("link")
.addAttribute("rel", rel)
.addAttribute("href", href);
.addAttribute("rel", rel)
.addAttribute("href", href);
}

private DOMElement withNamespace(String name) {
Expand All @@ -105,6 +117,10 @@ private DOMElement withNamespace(String name) {
return element;
}

private DOMElement withNamespace(String prefix, String name) {
return new DOMElement(name, current().getNamespaceForPrefix(prefix));
}

private Optional<Namespace> getDefaultNameSpace() {
return Optional.ofNullable(current().getNamespace());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import java.util.stream.Collectors;

import static java.nio.charset.StandardCharsets.UTF_8;


public class JUnitReportGenerator {

public static void main(String[] args) throws Exception {
Document doc = new SAXReader().read(new FileInputStream(new File("/home/cruise/sample_junit.xml")));
Document doc = new SAXReader().read(new FileInputStream("/home/cruise/sample_junit.xml"));
Element suite = (Element) doc.selectSingleNode("//testsuite");
Element rootElement = doc.getRootElement();
for (int i = 0; i < 50000; i++) {
Element copy = suite.createCopy();
setAttr(i, copy, "name");
setAttr(i, copy, "hostname");
List<Element> elements = copy.selectNodes(".//testcase");
List<Element> elements = copy.selectNodes(".//testcase")
.stream()
.filter(Element.class::isInstance)
.map(Element.class::cast)
.collect(Collectors.toList());
for (Element element : elements) {
setAttr(i, element, "classname");
setAttr(i, element, "name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.thoughtworks.go.domain.feed.stage.StageFeedEntry;
import com.thoughtworks.go.junit5.FileSource;
import com.thoughtworks.go.util.DateUtils;
import com.thoughtworks.go.util.GoConstants;
import com.thoughtworks.go.util.SystemEnvironment;
import org.dom4j.Document;
import org.junit.jupiter.params.ParameterizedTest;
Expand Down Expand Up @@ -76,6 +77,6 @@ private static StageFeedEntry passed() {
private static StageFeedEntry cancelled() {
Date date = DateUtils.parseISO8601("2019-12-31T07:28:30+05:30");
StageIdentifier identifier = new StageIdentifier("up42", 2, "integration-tests", "100");
return new StageFeedEntry(1L, 1L, identifier, 123L, date, StageResult.Cancelled, "", "Bob", "Admin");
return new StageFeedEntry(1L, 1L, identifier, 123L, date, StageResult.Cancelled, GoConstants.APPROVAL_MANUAL, "Bob", "Admin");
}
}
3 changes: 3 additions & 0 deletions server/src/test-fast/resources/feeds/stages-with-entries.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<title><![CDATA[up42(2) stage integration-tests(100) Cancelled]]></title>
<updated>2019-12-31T01:58:30Z</updated>
<id>https://go-server/go/pipelines/up42/2/integration-tests/100</id>
<go:author xmlns:go="http://www.thoughtworks-studios.com/ns/go">
<go:name><![CDATA[Bob]]></go:name>
</go:author>
<author>
<name><![CDATA[bob]]></name>
<email>bob@gocd.org</email>
Expand Down