File tree 2 files changed +10
-9
lines changed
main/java/org/codehaus/plexus/util/xml
test/java/org/codehaus/plexus/util/xml
2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 18
18
19
19
import java .io .PrintWriter ;
20
20
import java .io .Writer ;
21
+ import java .util .ArrayDeque ;
22
+ import java .util .Deque ;
21
23
import java .util .LinkedList ;
22
24
import java .util .regex .Matcher ;
23
25
import java .util .regex .Pattern ;
@@ -35,7 +37,7 @@ public class PrettyPrintXMLWriter
35
37
36
38
private PrintWriter writer ;
37
39
38
- private LinkedList <String > elementStack = new LinkedList < String >();
40
+ private final Deque <String > elementStack = new ArrayDeque < >();
39
41
40
42
private boolean tagInProgress ;
41
43
@@ -307,11 +309,6 @@ public void endElement()
307
309
{
308
310
finishTag ();
309
311
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.
315
312
write ( "</" );
316
313
write ( elementStack .removeLast () );
317
314
write ( ">" );
@@ -518,7 +515,7 @@ protected String getDocType()
518
515
/**
519
516
* @return the current elementStack;
520
517
*/
521
- protected LinkedList <String > getElementStack ()
518
+ protected Deque <String > getElementStack ()
522
519
{
523
520
return elementStack ;
524
521
}
Original file line number Diff line number Diff line change 18
18
19
19
import java .io .File ;
20
20
import java .io .IOException ;
21
- import java .io .OutputStreamWriter ;
22
21
import java .io .StringWriter ;
22
+ import java .io .Writer ;
23
+ import java .nio .charset .StandardCharsets ;
23
24
import java .nio .file .Files ;
24
25
import java .util .NoSuchElementException ;
25
26
29
30
import org .junit .jupiter .api .AfterEach ;
30
31
import org .junit .jupiter .api .BeforeEach ;
31
32
import org .junit .jupiter .api .Test ;
33
+ import org .junit .jupiter .api .condition .DisabledForJreRange ;
34
+ import org .junit .jupiter .api .condition .JRE ;
32
35
33
36
import static org .junit .jupiter .api .Assertions .assertEquals ;
34
37
import static org .junit .jupiter .api .Assertions .assertThrows ;
@@ -178,6 +181,7 @@ public void testendElementAlreadyClosed()
178
181
*
179
182
* @throws java.io.IOException if an I/O error occurs
180
183
*/
184
+ @ DisabledForJreRange (min = JRE .JAVA_8 )
181
185
@ Test
182
186
public void testIssue51DetectJava7ConcatenationBug ()
183
187
throws IOException
@@ -191,7 +195,7 @@ public void testIssue51DetectJava7ConcatenationBug()
191
195
192
196
int iterations = 20000 ;
193
197
194
- try ( OutputStreamWriter osw = new OutputStreamWriter ( Files .newOutputStream ( xmlFile .toPath () ), "UTF-8" ) )
198
+ try ( Writer osw = Files .newBufferedWriter ( xmlFile .toPath (), StandardCharsets . UTF_8 ) )
195
199
{
196
200
writer = new PrettyPrintXMLWriter ( osw );
197
201
for ( int i = 0 ; i < iterations ; ++i )
You can’t perform that action at this time.
0 commit comments