Skip to content

Commit 31ae1bf

Browse files
committed
Remove String#repeat(int) in test
Not available in Java 8.
1 parent 6ca4ecf commit 31ae1bf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/test/java/com/rabbitmq/client/PemReaderTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.security.KeyStore;
1919
import java.security.cert.X509Certificate;
20+
import java.util.Collections;
2021
import java.util.List;
2122
import java.util.Optional;
2223
import org.junit.jupiter.api.Test;
@@ -104,7 +105,11 @@ void testNullPrivateKeyContent() {
104105
@Test
105106
void testRedosResilienceLongDashString() {
106107
String dosPayload =
107-
"-----BEGIN " + "-".repeat(1000) + "-----\n" + "data\n" + "-----END CERTIFICATE-----";
108+
"-----BEGIN "
109+
+ String.join("", Collections.nCopies(1000, "-"))
110+
+ "-----\n"
111+
+ "data\n"
112+
+ "-----END CERTIFICATE-----";
108113
long startTime = System.nanoTime();
109114
try {
110115
PemReader.readCertificateChain(dosPayload);
@@ -118,7 +123,7 @@ void testRedosResilienceLongDashString() {
118123
void testRedosResilienceRepeatedPattern() {
119124
String dosPayload =
120125
"-----BEGIN "
121-
+ "CERTIFICATE ".repeat(100)
126+
+ String.join("", Collections.nCopies(100, "CERTIFICATE "))
122127
+ "-----\ndata\n-----END CERTIFICATE-----";
123128
long startTime = System.nanoTime();
124129
try {

0 commit comments

Comments
 (0)