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.

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.

1 participant