You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by tm...@apache.org on 2022/03/09 10:08:15 UTC
[sling-org-apache-sling-discovery-commons] branch master updated: SLING-7969 - Memory leak in DiscoveryLiteDescriptor
This is an automated email from the ASF dual-hosted git repository.
tmaret pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-discovery-commons.git
The following commit(s) were added to refs/heads/master by this push:
new edba8e9 SLING-7969 - Memory leak in DiscoveryLiteDescriptor
new 9baf6d5 Merge pull request #5 from tmaret/SLING-7969
edba8e9 is described below
commit edba8e9d8a5ec21f6a95945440e9c9825f00e666
Author: tmaret <tm...@adobe.com>
AuthorDate: Tue Oct 2 10:11:58 2018 +0200
SLING-7969 - Memory leak in DiscoveryLiteDescriptor
* Close the JsonReader instance when the Json descriptor has been read
---
.../commons/providers/spi/base/DiscoveryLiteDescriptor.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java
index cce9875..e55b93d 100644
--- a/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java
+++ b/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java
@@ -27,6 +27,7 @@ import javax.jcr.Session;
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
+import javax.json.JsonReader;
import javax.json.JsonReaderFactory;
import org.apache.sling.api.resource.ResourceResolver;
@@ -57,8 +58,10 @@ public class DiscoveryLiteDescriptor {
if (descriptorStr == null) {
throw new Exception("No value available for descriptor " + OAK_DISCOVERYLITE_CLUSTERVIEW);
}
- JsonObject descriptor = jsonReaderFactory.createReader(new StringReader(descriptorStr)).readObject();
- return new DiscoveryLiteDescriptor(descriptor);
+ try (JsonReader jsonReader = jsonReaderFactory.createReader(new StringReader(descriptorStr))) {
+ JsonObject descriptor = jsonReader.readObject();
+ return new DiscoveryLiteDescriptor(descriptor);
+ }
}
/** the actual descriptor **/