Skip to content

AMBARI-26596: Fixing fd leak during kerberizing#4124

Open
HalimKim wants to merge 1 commit intoapache:trunkfrom
HalimKim:AMBARI-26596
Open

AMBARI-26596: Fixing fd leak during kerberizing#4124
HalimKim wants to merge 1 commit intoapache:trunkfrom
HalimKim:AMBARI-26596

Conversation

@HalimKim
Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Using try-with-resources instead of just try in AbstractKerberosDescriptorFactory.java and AmbariMetaInfo.java

AbstractKerberosDescriptorFactory.java:

-      try {
-        return new Gson().fromJson(new FileReader(file),
+      try (FileReader reader = new FileReader(file)) {
+        return new Gson().fromJson(reader,
             new TypeToken<Map<String, Object>>() {
             }.getType());

AmbariMetaInfo.java:

-      try {
-        map = gson.fromJson(new FileReader(svc.getMetricsFile()), type);
+      try (FileReader reader = new FileReader(svc.getMetricsFile())) {
+        map = gson.fromJson(reader, type);

How was this patch tested?

manual tests done
I've built ambari-server jar file and updated my original ambari-server jar.
With the change, I've tried kerberizing test in my cluster.

@himanshumaurya09876
Copy link
Copy Markdown
Contributor

himanshumaurya09876 commented Apr 27, 2026

Thanks for catching this and updating the FileReader usage to try-with-resources. It’s a clean improvement that helps prevent resource leaks and makes the code more robust. Appreciate the thoughtful fix.
Can you please check and fix at other places as well like Runner.java, ThemeModule.java etc.

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