From 329f4de92bca01ff3075bf47570e3164cf9cec37 Mon Sep 17 00:00:00 2001 From: Andrey Pleskach Date: Fri, 3 Nov 2023 13:05:19 +0100 Subject: [PATCH] Fix for OpenSAML 4.3 Signed-off-by: Andrey Pleskach --- plugin-security.policy | 1 - .../shared/primitive/CleanerSupport.java | 21 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/main/java/net/shibboleth/shared/primitive/CleanerSupport.java diff --git a/plugin-security.policy b/plugin-security.policy index a4e4a66c73..65b6b22fee 100644 --- a/plugin-security.policy +++ b/plugin-security.policy @@ -76,7 +76,6 @@ grant { //SAML policy permission java.util.PropertyPermission "*", "read,write"; - permission org.opensearch.secure_sm.ThreadPermission "modifyArbitraryThread"; }; grant codeBase "${codebase.netty-common}" { diff --git a/src/main/java/net/shibboleth/shared/primitive/CleanerSupport.java b/src/main/java/net/shibboleth/shared/primitive/CleanerSupport.java new file mode 100644 index 0000000000..2cc27ccce3 --- /dev/null +++ b/src/main/java/net/shibboleth/shared/primitive/CleanerSupport.java @@ -0,0 +1,21 @@ +package net.shibboleth.shared.primitive; + +import java.lang.ref.Cleaner; +import javax.annotation.Nonnull; + +import org.opensearch.common.util.concurrent.OpenSearchExecutors; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public final class CleanerSupport { + @Nonnull + private static final Logger LOG = LoggerFactory.getLogger(CleanerSupport.class); + + private CleanerSupport() {} + + @Nonnull + public static Cleaner getInstance(@Nonnull final Class requester) { + LOG.debug("Creating new java.lang.ref.Cleaner instance requested by class: {}", requester.getName()); + return Cleaner.create(OpenSearchExecutors.daemonThreadFactory("cleaners")); + } +}