Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RANGER-5131: remove finalize from policy engine #531

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

vyommani
Copy link
Contributor

What changes were proposed in this pull request?

Removal of finalize() method from PolicyEngine class

As part of our efforts to ensure compatibility with future JDK versions, this code change removes the deprecated finalize() method from the PolicyEngine class. The finalize() method has been deprecated since JDK 9 and is slated for removal in future JDK versions.

Impact Analysis

A thorough analysis was conducted to assess the impact of removing the finalize() method. The results indicate that there is no adverse impact on the functionality of the PolicyEngine class.

Existing Cleanup Mechanisms

It's worth noting that we already have a cleanup() method in the RangerBasePlugin class, which allows users to release resources held by the PolicyEngine. This method provides a manual way to perform cleanup operations, ensuring that resources are properly released when needed.

How was this patch tested?

mvn clean install

@@ -300,13 +300,4 @@ public Properties readProperties(String fileName) {

return ret;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it okay to simply remove finalize() methods, without an alternate method to execute the cleanup performed currently?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the finalize() method without an alternative cleanup method is not advisable. However, my analysis reveals that we already have robust cleanup mechanisms in place.
Upon reviewing the Ranger source code, I found that the PolicyEngine is referenced in the following classes:

RangerPolicyAdminImpl
RangerPolicyEngineImpl

Both RangerPolicyAdminImpl and RangerPolicyEngineImpl have a releaseResources(boolean isForced) method, which calls the preCleanup(isForced) method on the PolicyEngine. This preCleanup method performs the following cleanup operations:

Calls policyRepository.preCleanup()
Calls tagPolicyRepository.preCleanup()
Calls zonePolicyRepositories.preCleanup()

These preCleanup methods on the repository iterate through the Context Enrichers and call preCleanup on individual instances.

Upon further review, I noticed that the setPolicies method in RangerBasePlugin calls the releaseResources method on RangerPolicyEngineImpl. This ensures that resources held by the old policy engine are properly released before updating to the new policy.

Given that we already have alternative cleanup method (releaseResources), I believe we can safely remove the finalize() method. Please review my findings and let me know if I've missed any code paths.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants