forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing ehcache flaky test (opensearch-project#12764)
* Fixing ehcache flaky test Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com> * Adding a ehcache issue reference for thread leak issue Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com> * Updating comment Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com> --------- Signed-off-by: Sagar Upadhyaya <sagar.upadhyaya.121@gmail.com>
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
.../cache-ehcache/src/test/java/org/opensearch/cache/store/disk/EhcacheThreadLeakFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.cache.store.disk; | ||
|
||
import com.carrotsearch.randomizedtesting.ThreadFilter; | ||
|
||
/** | ||
* In Ehcache(as of 3.10.8), while calling remove/invalidate() on entries causes to start a daemon thread in the | ||
* background to clean up the stale offheap memory associated with the disk cache. And this thread is not closed even | ||
* after we try to close the cache or cache manager. Considering that it requires a node restart to switch between | ||
* different cache plugins, this shouldn't be a problem for now. | ||
* | ||
* See: https://github.com/ehcache/ehcache3/issues/3204 | ||
*/ | ||
public class EhcacheThreadLeakFilter implements ThreadFilter { | ||
|
||
private static final String OFFENDING_THREAD_NAME = "MappedByteBufferSource"; | ||
|
||
@Override | ||
public boolean reject(Thread t) { | ||
return t.getName().startsWith(OFFENDING_THREAD_NAME); | ||
} | ||
} |