sabberworm commented on a change in pull request #2: SLING-8419 write back 
configuration in OSGi JSON format
URL: 
https://github.com/apache/sling-org-apache-sling-installer-provider-file/pull/2#discussion_r410448894
 
 

 ##########
 File path: 
src/main/java/org/apache/sling/installer/provider/file/impl/FileInstaller.java
 ##########
 @@ -191,23 +197,18 @@ private UpdateResult handleUpdate(final String 
resourceType,
             } else {
                 // add
                 final FileMonitor first = this.monitors.get(0);
-                path = first.getRoot().getAbsolutePath() + '/' + id + 
".config";
+                path = first.getRoot().getAbsolutePath() + '/' + id + 
CONFIG_FILE_EXTENSION;
                 prefix = first.getListener().getScheme();
                 logger.debug("Add of {} at {}", resourceType, path);
             }
 
             final File file = new File(path);
             file.getParentFile().mkdirs();
-            final FileOutputStream fos = new FileOutputStream(file);
-            try {
-                fos.write("# Configuration created by Apache Sling File 
Installer\n".getBytes("UTF-8"));
-                ConfigurationHandler.write(fos, dict);
-            } finally {
-                try {
-                    fos.close();
-                } catch (final IOException ignore) {}
-            }
-
+            try (OutputStream fos = new BufferedOutputStream(new 
FileOutputStream(file))) {
+                fos.write("# Configuration created by Apache Sling File 
Installer\n".getBytes(StandardCharsets.UTF_8));
 
 Review comment:
   I’m not sure the `#` character introduces a valid comment in JSON…
   Then again 
https://sling.apache.org/documentation/bundles/configuration-installer-factory.html
 mentions being allowed to use `//` comments, which also would not be valid 
JSON…

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to