Skip to content
Permalink
Browse files

8249258: java/util/StringJoiner/StringJoinerTest.java failed due to OOM

Reviewed-by: dcubed, rriggs
  • Loading branch information
JimLaskey committed Jul 15, 2020
1 parent b678149 commit a640835c62c6275a2e6876cb0bb8efd48c5144bb
Showing with 7 additions and 14 deletions.
  1. +7 −14 test/jdk/java/util/StringJoiner/StringJoinerTest.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,7 @@
*/
/**
* @test
* @bug 5015163 7172553
* @bug 5015163 7172553 8249258
* @summary tests StringJoinerTest
* @modules java.base/jdk.internal.util
* @requires os.maxMemory > 4G
@@ -49,6 +49,7 @@
private static final String FOUR = "Four";
private static final String FIVE = "Five";
private static final String DASH = "-";
private static final String MAX_STRING = "*".repeat(MAX_ARRAY_LENGTH);

public void addAddAll() {
StringJoiner sj = new StringJoiner(DASH, "{", "}");
@@ -327,43 +328,35 @@ public void testDelimiterCombinations() {
}

public void OOM1() {
String maxString = "*".repeat(MAX_ARRAY_LENGTH);

try {
new StringJoiner(maxString, maxString, maxString).toString();
new StringJoiner(MAX_STRING, MAX_STRING, MAX_STRING).toString();
fail("Should have thrown OutOfMemoryError");
} catch (OutOfMemoryError ex) {
// okay
}
}

public void OOM2() {
String maxString = "*".repeat(MAX_ARRAY_LENGTH);

try {
new StringJoiner(maxString, maxString, "").toString();
new StringJoiner(MAX_STRING, MAX_STRING, "").toString();
fail("Should have thrown OutOfMemoryError");
} catch (OutOfMemoryError ex) {
// okay
}
}

public void OOM3() {
String maxString = "*".repeat(MAX_ARRAY_LENGTH);

try {
new StringJoiner(maxString, "", maxString).toString();
new StringJoiner(MAX_STRING, "", MAX_STRING).toString();
fail("Should have thrown OutOfMemoryError");
} catch (OutOfMemoryError ex) {
// okay
}
}

public void OOM4() {
String maxString = "*".repeat(MAX_ARRAY_LENGTH);

try {
new StringJoiner("", maxString, maxString).toString();
new StringJoiner("", MAX_STRING, MAX_STRING).toString();
fail("Should have thrown OutOfMemoryError");
} catch (OutOfMemoryError ex) {
// okay

0 comments on commit a640835

Please sign in to comment.