SLING-2624 : Improving Jackrabbit integration with OSGi Service Registry. Minor cosmetics

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1401228 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/sling/jcr/jackrabbit/base/config/OsgiBeanFactory.java b/src/main/java/org/apache/sling/jcr/jackrabbit/base/config/OsgiBeanFactory.java
index f55cd45..3ec4e08 100644
--- a/src/main/java/org/apache/sling/jcr/jackrabbit/base/config/OsgiBeanFactory.java
+++ b/src/main/java/org/apache/sling/jcr/jackrabbit/base/config/OsgiBeanFactory.java
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.Reader;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -92,7 +93,7 @@
         this.tracker = new ServiceTracker(bundleContext, filter, this);
     }
 
-    public void initialize(InputSource configSource) throws IOException, ConfigurationException {
+    public void initialize(final InputSource configSource) throws ConfigurationException {
         determineDependencies(configSource);
         createClassNameMappings();
         tracker.open();
@@ -192,19 +193,26 @@
         }
     }
 
-    private void determineDependencies(InputSource source) throws ConfigurationException, IOException {
-        Properties p = new Properties();
+    private void determineDependencies(final InputSource source) throws ConfigurationException {
+        final Properties p = new Properties();
         p.putAll(System.getProperties());
         p.setProperty(RepositoryConfigurationParser.REPOSITORY_HOME_VARIABLE, "/fake/path");
-        RepositoryConfigurationParser parser = new RepositoryConfigurationParser(p);
+
+        final RepositoryConfigurationParser parser = new RepositoryConfigurationParser(p);
         parser.setConfigVisitor(new DepFinderBeanConfigVisitor());
 
         try {
             parser.parseRepositoryConfig(source);
         } finally {
-            InputStream is = source.getByteStream();
+            // close source
+            final InputStream is = source.getByteStream();
             if (is != null) {
-                is.close();
+                try { is.close(); } catch (final IOException ignore) {}
+            } else {
+                final Reader r = source.getCharacterStream();
+                if ( r != null ) {
+                    try { r.close(); } catch (final IOException ignore) {}
+                }
             }
         }