Skip to content

Commit 48fdb3b

Browse files
authored
Filter out JNA Cleaner thread from test leak detection (#114668) (#124162) (#124166)
JNA has a static thread which handles cleaning up native memory references. This commit adds the thread name to those filtered out of thread leak detection since it lives for the lifetime of the JDK (yet might be started in the middle of a test). closes #114555
1 parent 0473173 commit 48fdb3b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

test/framework/src/main/java/org/elasticsearch/test/ESTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
@ThreadLeakScope(Scope.SUITE)
231231
@ThreadLeakLingering(linger = 5000) // 5 sec lingering
232232
@TimeoutSuite(millis = 20 * TimeUnits.MINUTE)
233-
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class, NettyGlobalThreadsFilter.class })
233+
@ThreadLeakFilters(filters = { GraalVMThreadsFilter.class, NettyGlobalThreadsFilter.class, JnaCleanerThreadsFilter.class })
234234
@LuceneTestCase.SuppressSysoutChecks(bugUrl = "we log a lot on purpose")
235235
// we suppress pretty much all the lucene codecs for now, except asserting
236236
// assertingcodec is the winner for a codec here: it finds bugs and gives clear exceptions.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.test;
11+
12+
import com.carrotsearch.randomizedtesting.ThreadFilter;
13+
14+
/**
15+
* JNA has a special thread to cleanup native memory references. It is static per JVM, so we
16+
* filter it out of test leak detection.
17+
*/
18+
public class JnaCleanerThreadsFilter implements ThreadFilter {
19+
@Override
20+
public boolean reject(Thread t) {
21+
return t.getName().equals("JNA Cleaner");
22+
}
23+
}

0 commit comments

Comments
 (0)