diff --git a/pdp/src/main/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrap.java b/pdp/src/main/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrap.java
deleted file mode 100644
index fe1948c504..0000000000
--- a/pdp/src/main/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrap.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ranger.pdp.rest;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-/**
- * Starts {@link RangerPdpREST} service-account refresh from the JAX-RS / HK2 runtime
- * (same lifecycle as delegated authorization checks), mirroring audit ingestor's bootstrap.
- */
-@Singleton
-public class PdpServiceAccountRefreshBootstrap {
- private final RangerPdpREST rangerPdpREST;
-
- @Inject
- public PdpServiceAccountRefreshBootstrap(RangerPdpREST rangerPdpREST) {
- this.rangerPdpREST = rangerPdpREST;
- }
-
- @PostConstruct
- public void start() {
- rangerPdpREST.startServiceAccountUsersRefresh();
- }
-
- @PreDestroy
- public void stop() {
- rangerPdpREST.stopServiceAccountUsersRefresh();
- }
-}
diff --git a/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpApplication.java b/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpApplication.java
index ecaaee48fb..42371b452d 100644
--- a/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpApplication.java
+++ b/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpApplication.java
@@ -35,7 +35,6 @@
*
{@link AuthorizerBinder} – HK2 binder that makes the {@link RangerAuthorizer}
* instance injectable into {@link RangerPdpREST} via {@code @Inject}
* {@link RangerPdpREST} – the JAX-RS resource class
- * {@link PdpServiceAccountRefreshBootstrap} – service-account refresh lifecycle
*
*/
public class RangerPdpApplication extends ResourceConfig {
@@ -43,7 +42,6 @@ public RangerPdpApplication(RangerAuthorizer authorizer, RangerPdpConfig config)
register(JacksonFeature.class);
register(new AuthorizerBinder(authorizer, config));
register(RangerPdpREST.class);
- register(PdpServiceAccountRefreshBootstrap.class);
}
private static class AuthorizerBinder extends AbstractBinder {
diff --git a/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpREST.java b/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpREST.java
index ae509627b0..45e6af63af 100644
--- a/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpREST.java
+++ b/pdp/src/main/java/org/apache/ranger/pdp/rest/RangerPdpREST.java
@@ -46,6 +46,7 @@
import org.slf4j.LoggerFactory;
import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.servlet.ServletContext;
@@ -131,12 +132,14 @@ public class RangerPdpREST {
@PostConstruct
public void initialize() {
initializeDelegationUsersOnly();
+ startServiceAccountUsersRefresh();
+ }
+
+ @PreDestroy
+ public void destroy() {
+ stopServiceAccountUsersRefresh();
}
- /**
- * Starts Admin {@code service.account.users} polling. Invoked from {@link PdpServiceAccountRefreshBootstrap}
- * after {@link #initialize()} has loaded static delegation config.
- */
public synchronized void startServiceAccountUsersRefresh() {
Properties properties = config != null ? config.getAuthzProperties() : new Properties();
startServiceAccountUsersRefresh(properties);
diff --git a/pdp/src/test/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrapTest.java b/pdp/src/test/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrapTest.java
deleted file mode 100644
index 8b0f617bd9..0000000000
--- a/pdp/src/test/java/org/apache/ranger/pdp/rest/PdpServiceAccountRefreshBootstrapTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.ranger.pdp.rest;
-
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-class PdpServiceAccountRefreshBootstrapTest {
- @Test
- void startStopDelegateToRangerPdpREST() {
- TrackingPdpRest rest = new TrackingPdpRest();
- PdpServiceAccountRefreshBootstrap bootstrap = new PdpServiceAccountRefreshBootstrap(rest);
-
- bootstrap.start();
- bootstrap.stop();
-
- assertTrue(rest.startCalled);
- assertTrue(rest.stopCalled);
- }
-
- private static final class TrackingPdpRest extends RangerPdpREST {
- boolean startCalled;
- boolean stopCalled;
-
- @Override
- public synchronized void startServiceAccountUsersRefresh() {
- startCalled = true;
- }
-
- @Override
- public synchronized void stopServiceAccountUsersRefresh() {
- stopCalled = true;
- }
- }
-}