Skip to content

Commit 47912f5

Browse files
committed
sanitize content
1 parent b4869f5 commit 47912f5

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

test/fixtures/gcs-fixture/src/test/java/fixture/gcs/MultipartUploadTests.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.elasticsearch.test.ESTestCase;
1717

1818
import java.io.IOException;
19+
import java.util.Arrays;
1920

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

@@ -24,14 +25,10 @@ public class MultipartUploadTests extends ESTestCase {
2425
// produces content that does not contain boundary
2526
static String randomPartContent(int len, String boundary) {
2627
assert len > 0 && boundary.isEmpty() == false;
27-
var n = 100;
28-
for (var i = 0; i < 100; i++) {
29-
var content = randomAlphanumericOfLength(len);
30-
if (content.contains(boundary) == false) {
31-
return content;
32-
}
33-
}
34-
throw new IllegalStateException("cannot generate part content for len=" + len + " boundary=" + boundary);
28+
var content = randomAlphanumericOfLength(len);
29+
var replacement = boundary.getBytes(UTF_8);
30+
replacement[0]++; // change single char to make it different from original
31+
return content.replace(boundary, Arrays.toString(replacement));
3532
}
3633

3734
public void testGenericMultipart() throws IOException {

0 commit comments

Comments
 (0)