Skip to content

Commit 2c9d269

Browse files
committed
Create BouncyCastleThreadFilter
Signed-off-by: Craig Perkins <cwperx@amazon.com>
1 parent c699e1c commit 2c9d269

File tree

8 files changed

+64
-0
lines changed

8 files changed

+64
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.common.ssl;
10+
11+
import com.carrotsearch.randomizedtesting.ThreadFilter;
12+
13+
/**
14+
* ThreadFilter to exclude ThreadLeak checks for BC’s global background threads
15+
*/
16+
public class BouncyCastleThreadFilter implements ThreadFilter {
17+
@Override
18+
public boolean reject(Thread t) {
19+
String n = t.getName();
20+
// Ignore BC’s global background threads
21+
return "BC Disposal Daemon".equals(n) || "BC Cleanup Executor".equals(n);
22+
}
23+
}

libs/ssl-config/src/test/java/org/opensearch/common/ssl/PemKeyConfigTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.common.ssl;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import org.opensearch.test.OpenSearchTestCase;
3638
import org.hamcrest.Matchers;
3739

@@ -55,6 +57,7 @@
5557
import static org.hamcrest.Matchers.iterableWithSize;
5658
import static org.hamcrest.Matchers.notNullValue;
5759

60+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
5861
public class PemKeyConfigTests extends OpenSearchTestCase {
5962
private static final int IP_NAME = 7;
6063
private static final int DNS_NAME = 2;

libs/ssl-config/src/test/java/org/opensearch/common/ssl/PemTrustConfigTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.common.ssl;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import org.opensearch.test.OpenSearchTestCase;
3638
import org.hamcrest.Matchers;
3739

@@ -51,6 +53,7 @@
5153
import java.util.stream.Collectors;
5254
import java.util.stream.Stream;
5355

56+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
5457
public class PemTrustConfigTests extends OpenSearchTestCase {
5558

5659
public void testBuildTrustConfigFromSinglePemFile() throws Exception {

libs/ssl-config/src/test/java/org/opensearch/common/ssl/PemUtilsTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.common.ssl;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
3638
import org.bouncycastle.asn1.pkcs.PrivateKeyInfo;
3739
import org.opensearch.test.OpenSearchTestCase;
@@ -56,6 +58,7 @@
5658
import static org.hamcrest.Matchers.equalTo;
5759
import static org.hamcrest.core.StringContains.containsString;
5860

61+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
5962
public class PemUtilsTests extends OpenSearchTestCase {
6063

6164
private static final Supplier<char[]> EMPTY_PASSWORD = () -> new char[0];

libs/ssl-config/src/test/java/org/opensearch/common/ssl/SslConfigurationLoaderTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.common.ssl;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import org.opensearch.common.settings.MockSecureSettings;
3638
import org.opensearch.common.settings.Settings;
3739
import org.opensearch.core.common.settings.SecureString;
@@ -51,6 +53,7 @@
5153
import static org.hamcrest.Matchers.is;
5254
import static org.hamcrest.Matchers.notNullValue;
5355

56+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
5457
public class SslConfigurationLoaderTests extends OpenSearchTestCase {
5558

5659
private final String STRONG_PRIVATE_SECRET = "6!6428DQXwPpi7@$ggeg/=";

libs/ssl-config/src/test/java/org/opensearch/common/ssl/SslDiagnosticsTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.common.ssl;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import org.opensearch.common.Nullable;
3638
import org.opensearch.test.OpenSearchTestCase;
3739
import org.hamcrest.Matchers;
@@ -59,6 +61,7 @@
5961

6062
import org.mockito.Mockito;
6163

64+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
6265
public class SslDiagnosticsTests extends OpenSearchTestCase {
6366

6467
// Some constants for use in mock certificates
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* SPDX-License-Identifier: Apache-2.0
3+
*
4+
* The OpenSearch Contributors require contributions made to
5+
* this file be licensed under the Apache-2.0 license or a
6+
* compatible open source license.
7+
*/
8+
9+
package org.opensearch.index.reindex;
10+
11+
import com.carrotsearch.randomizedtesting.ThreadFilter;
12+
13+
/**
14+
* ThreadFilter to exclude ThreadLeak checks for BC’s global background threads
15+
*/
16+
public class BouncyCastleThreadFilter implements ThreadFilter {
17+
@Override
18+
public boolean reject(Thread t) {
19+
String n = t.getName();
20+
// Ignore BC’s global background threads
21+
return "BC Disposal Daemon".equals(n) || "BC Cleanup Executor".equals(n);
22+
}
23+
}

modules/reindex/src/test/java/org/opensearch/index/reindex/ReindexRestClientSslTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232

3333
package org.opensearch.index.reindex;
3434

35+
import com.carrotsearch.randomizedtesting.annotations.ThreadLeakFilters;
36+
3537
import com.sun.net.httpserver.HttpsConfigurator;
3638
import com.sun.net.httpserver.HttpsExchange;
3739
import com.sun.net.httpserver.HttpsParameters;
@@ -82,6 +84,7 @@
8284
* right SSL keys + trust settings.
8385
*/
8486
@SuppressForbidden(reason = "use http server")
87+
@ThreadLeakFilters(filters = BouncyCastleThreadFilter.class)
8588
public class ReindexRestClientSslTests extends OpenSearchTestCase {
8689

8790
private static final String STRONG_PRIVATE_SECRET = "6!6428DQXwPpi7@$ggeg/=";

0 commit comments

Comments
 (0)