File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
main/java/org/codehaus/plexus/util/xml
test/java/org/codehaus/plexus/util/xml Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 1818
1919import java .io .PrintWriter ;
2020import java .io .Writer ;
21+ import java .util .ArrayDeque ;
22+ import java .util .Deque ;
2123import java .util .LinkedList ;
2224import java .util .regex .Matcher ;
2325import java .util .regex .Pattern ;
@@ -35,7 +37,7 @@ public class PrettyPrintXMLWriter
3537
3638 private PrintWriter writer ;
3739
38- private LinkedList <String > elementStack = new LinkedList < String >();
40+ private final Deque <String > elementStack = new ArrayDeque < >();
3941
4042 private boolean tagInProgress ;
4143
@@ -307,11 +309,6 @@ public void endElement()
307309 {
308310 finishTag ();
309311
310- // see issue #51: https://github.com/codehaus-plexus/plexus-utils/issues/51
311- // Rationale: replaced 1 write() with string concatenations with 3 write()
312- // (this avoids the string concatenation optimization bug detected in Java 7)
313- // TODO: change the below code to a more efficient expression when the library
314- // be ready to target Java 8.
315312 write ( "</" );
316313 write ( elementStack .removeLast () );
317314 write ( ">" );
@@ -518,7 +515,7 @@ protected String getDocType()
518515 /**
519516 * @return the current elementStack;
520517 */
521- protected LinkedList <String > getElementStack ()
518+ protected Deque <String > getElementStack ()
522519 {
523520 return elementStack ;
524521 }
Original file line number Diff line number Diff line change 1818
1919import java .io .File ;
2020import java .io .IOException ;
21- import java .io .OutputStreamWriter ;
2221import java .io .StringWriter ;
22+ import java .io .Writer ;
23+ import java .nio .charset .StandardCharsets ;
2324import java .nio .file .Files ;
2425import java .util .NoSuchElementException ;
2526
2829import org .codehaus .plexus .util .StringUtils ;
2930import org .junit .jupiter .api .AfterEach ;
3031import org .junit .jupiter .api .BeforeEach ;
32+ import org .junit .jupiter .api .Disabled ;
3133import org .junit .jupiter .api .Test ;
3234
3335import static org .junit .jupiter .api .Assertions .assertEquals ;
@@ -178,6 +180,7 @@ public void testendElementAlreadyClosed()
178180 *
179181 * @throws java.io.IOException if an I/O error occurs
180182 */
183+ @ Disabled ( "This test is only relevant on JDK 1.7, which is not supported anymore" )
181184 @ Test
182185 public void testIssue51DetectJava7ConcatenationBug ()
183186 throws IOException
@@ -191,7 +194,7 @@ public void testIssue51DetectJava7ConcatenationBug()
191194
192195 int iterations = 20000 ;
193196
194- try ( OutputStreamWriter osw = new OutputStreamWriter ( Files .newOutputStream ( xmlFile .toPath () ), "UTF-8" ) )
197+ try ( Writer osw = Files .newBufferedWriter ( xmlFile .toPath (), StandardCharsets . UTF_8 ) )
195198 {
196199 writer = new PrettyPrintXMLWriter ( osw );
197200 for ( int i = 0 ; i < iterations ; ++i )
You can’t perform that action at this time.
0 commit comments