This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.fsresource-1.3.0
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-fsresource.git

commit 8c0e64afc0f6ff9cd7db4d0bb1c4849f6d15c953
Author: Stefan Seifert <[email protected]>
AuthorDate: Tue Mar 14 10:59:07 2017 +0000

    SLING-6440 switch to latest jcr/contentparser API
    
    git-svn-id: 
https://svn.apache.org/repos/asf/sling/branches/fsresource-1.x@1786878 
13f79535-47bb-0310-9956-ffa450edef68
---
 .../fsprovider/internal/parser/ContentFileParserUtil.java  | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
 
b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
index ff83c00..cb7e222 100644
--- 
a/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
+++ 
b/src/main/java/org/apache/sling/fsprovider/internal/parser/ContentFileParserUtil.java
@@ -22,7 +22,10 @@ import static 
org.apache.jackrabbit.vault.util.Constants.DOT_CONTENT_XML;
 import static 
org.apache.sling.fsprovider.internal.parser.ContentFileTypes.JCR_XML_SUFFIX;
 import static 
org.apache.sling.fsprovider.internal.parser.ContentFileTypes.JSON_SUFFIX;
 
+import java.io.BufferedInputStream;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
 import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
@@ -68,10 +71,10 @@ class ContentFileParserUtil {
         }
         try {
             if (StringUtils.endsWith(file.getName(), JSON_SUFFIX)) {
-                return JSON_PARSER.parse(file);
+                return parse(JSON_PARSER, file);
             }
             else if (StringUtils.equals(file.getName(), DOT_CONTENT_XML) || 
StringUtils.endsWith(file.getName(), JCR_XML_SUFFIX)) {
-                return JCR_XML_PARSER.parse(file);
+                return parse(JCR_XML_PARSER, file);
             }
         }
         catch (Throwable ex) {
@@ -80,4 +83,11 @@ class ContentFileParserUtil {
         return null;
     }
 
+    private static Map<String,Object> parse(ContentParser contentParser, File 
file) throws IOException {
+        try (FileInputStream fis = new FileInputStream(file);
+                BufferedInputStream bis = new BufferedInputStream(fis)) {
+            return contentParser.parse(bis);
+        }
+    }
+    
 }

-- 
To stop receiving notification emails like this one, please contact
"[email protected]" <[email protected]>.

Reply via email to