Skip to content
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
3 changes: 1 addition & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ jobs:
# Works with Java 17+
matrix-exclude: >
[
{"jdk": "8"},
{"jdk": "11"}
{"jdk": "8"}
]

deploy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@

import javax.swing.text.html.HTML.Tag;

import java.io.File;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.file.Files;
import java.util.NoSuchElementException;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

/**
* Test of {@link org.codehaus.plexus.util.xml.PrettyPrintXMLWriter}
Expand Down Expand Up @@ -161,39 +155,6 @@ void testendElementAlreadyClosed() {
writer.endElement());
}

/**
* Issue #51: <a href="https://github.com/codehaus-plexus/plexus-utils/issues/51">Issue 51</a> Purpose: test if concatenation string
* optimization bug is present. Target environment: Java 7 (u79 and u80 verified) running on Windows. Detection
* strategy: Tries to build a big XML file (~750MB size) and with many nested tags to force the JVM to trigger the
* concatenation string optimization bug that throws a NoSuchElementException when calling endElement() method.
*
* @throws java.io.IOException if an I/O error occurs
*/
@Disabled("This test is only relevant on JDK 1.7, which is not supported anymore")
@Test
void issue51DetectJava7ConcatenationBug() throws Exception {
File dir = new File("target/test-xml");
if (!dir.exists()) {
assertTrue(dir.mkdir(), "cannot create directory test-xml");
}
File xmlFile = new File(dir, "test-issue-51.xml");

int iterations = 20000;

try (Writer osw = Files.newBufferedWriter(xmlFile.toPath())) {
writer = new PrettyPrintXMLWriter(osw);
for (int i = 0; i < iterations; ++i) {
writer.startElement(Tag.DIV.toString() + i);
writer.addAttribute("class", "someattribute");
}
for (int i = 0; i < iterations; ++i) {
writer.endElement(); // closes Tag.DIV + i
}
} catch (NoSuchElementException e) {
fail("Should not throw a NoSuchElementException");
}
}

private void writeXhtmlHead(XMLWriter writer) {
writer.startElement(Tag.HEAD.toString());
writer.startElement(Tag.TITLE.toString());
Expand Down
Loading