You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2025/03/05 17:05:21 UTC

(sling-org-apache-sling-bundleresource-impl) branch feature/SLING-12694-parent-62 created (now eaba1d8)

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

sseifert pushed a change to branch feature/SLING-12694-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git


      at eaba1d8  SLING-12694 apply spotless formatting

This branch includes the following new commits:

     new 74c06ec  SLING-12694 Update to Parent 62
     new eaba1d8  SLING-12694 apply spotless formatting

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(sling-org-apache-sling-bundleresource-impl) 02/02: SLING-12694 apply spotless formatting

Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a commit to branch feature/SLING-12694-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git

commit eaba1d8a2ea47746a623b3e77a733495ffe27d97
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Mar 5 18:05:13 2025 +0100

    SLING-12694 apply spotless formatting
---
 pom.xml                                            |  48 +++---
 .../sling/bundleresource/impl/Activator.java       |  38 ++---
 .../sling/bundleresource/impl/BundleResource.java  | 166 +++++++++++----------
 .../bundleresource/impl/BundleResourceCache.java   |  12 +-
 .../impl/BundleResourceIterator.java               |  32 ++--
 .../impl/BundleResourceProvider.java               |  52 ++++---
 .../impl/BundleResourceURLConnection.java          |   6 +-
 .../impl/BundleResourceURLStreamHandler.java       |   6 +-
 .../impl/BundleResourceWebConsolePlugin.java       |  77 +++++-----
 .../sling/bundleresource/impl/PathMapping.java     |  17 +--
 .../impl/BundleResourceProviderTest.java           |  80 ++++++----
 .../bundleresource/impl/BundleResourceTest.java    |  37 +++--
 .../bundleresource/impl/NoBundleContextTest.java   |  16 +-
 .../sling/bundleresource/impl/PathMappingTest.java |   4 +-
 .../impl/url/ResourceURLConnection.java            |   4 +-
 .../impl/url/ResourceURLStreamHandler.java         |  56 ++++---
 .../impl/url/ResourceURLStreamHandlerFactory.java  |   5 +-
 17 files changed, 339 insertions(+), 317 deletions(-)

diff --git a/pom.xml b/pom.xml
index 281631e..2899c4c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!--
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -30,36 +30,20 @@
     <version>2.3.5-SNAPSHOT</version>
 
     <name>Apache Sling Bundle Resource Provider</name>
-    <description>
-        Provides a ResourceProvider implementation supporting bundle
-        based resources.
-    </description>
-
-    <properties>
-        <sling.java.version>11</sling.java.version>
-        <project.build.outputTimestamp>2021-04-23T16:34:16Z</project.build.outputTimestamp>
-    </properties>
+    <description>Provides a ResourceProvider implementation supporting bundle
+        based resources.</description>
 
     <scm>
         <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git</connection>
         <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git</developerConnection>
-        <url>https://github.com/apache/sling-org-apache-sling-bundleresource-impl.git</url>
         <tag>HEAD</tag>
+        <url>https://github.com/apache/sling-org-apache-sling-bundleresource-impl.git</url>
     </scm>
 
-    <build>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-javadoc-plugin</artifactId>
-                <configuration>
-                    <excludePackageNames>
-                        org.apache.sling.bundleresource.impl
-                    </excludePackageNames>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
+    <properties>
+        <sling.java.version>11</sling.java.version>
+        <project.build.outputTimestamp>2021-04-23T16:34:16Z</project.build.outputTimestamp>
+    </properties>
     <dependencies>
         <dependency>
             <groupId>org.slf4j</groupId>
@@ -111,7 +95,7 @@
             <artifactId>org.osgi.annotation.bundle</artifactId>
             <scope>provided</scope>
         </dependency>
-        
+
         <!--  This is only used for some constants, no runtime dependency -->
         <dependency>
             <groupId>org.apache.jackrabbit</groupId>
@@ -146,9 +130,21 @@
         <dependency>
             <groupId>org.apache.johnzon</groupId>
             <artifactId>johnzon-core</artifactId>
-            <classifier>jakarta</classifier>
             <version>1.2.14</version>
+            <classifier>jakarta</classifier>
             <scope>test</scope>
         </dependency>
     </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <configuration>
+                    <excludePackageNames>org.apache.sling.bundleresource.impl</excludePackageNames>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
 </project>
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/Activator.java b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
index 682f3a5..58f614d 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/Activator.java
@@ -71,11 +71,11 @@ public class Activator implements BundleActivator, BundleListener {
         BundleResourceWebConsolePlugin.destroyPlugin();
 
         context.removeBundleListener(this);
-        for(final BundleResourceProvider[] providers : this.bundleResourceProviderMap.values()) {
-            for(final BundleResourceProvider p : providers) {
+        for (final BundleResourceProvider[] providers : this.bundleResourceProviderMap.values()) {
+            for (final BundleResourceProvider p : providers) {
                 try {
                     p.unregisterService();
-                } catch ( final IllegalStateException ise) {
+                } catch (final IllegalStateException ise) {
                     // might happen on shutdown
                 }
             }
@@ -111,24 +111,24 @@ public class Activator implements BundleActivator, BundleListener {
     private void addBundleResourceProvider(final Bundle bundle) {
         BundleResourceProvider[] providers = null;
         try {
-            synchronized ( this ) {
+            synchronized (this) {
                 // on startup we might get here twice for a bundle (listener and activator)
-                if ( bundleResourceProviderMap.get(bundle.getBundleId()) != null ) {
+                if (bundleResourceProviderMap.get(bundle.getBundleId()) != null) {
                     return;
                 }
                 final String prefixes = bundle.getHeaders().get(BUNDLE_RESOURCE_ROOTS);
                 if (prefixes != null) {
                     log.debug(
-                        "addBundleResourceProvider: Registering resources '{}' for bundle {}:{} ({}) as service ",
-                        new Object[] { prefixes, bundle.getSymbolicName(), bundle.getVersion(),
-                            bundle.getBundleId() });
+                            "addBundleResourceProvider: Registering resources '{}' for bundle {}:{} ({}) as service ",
+                            new Object[] {prefixes, bundle.getSymbolicName(), bundle.getVersion(), bundle.getBundleId()
+                            });
 
                     final PathMapping[] roots = PathMapping.getRoots(prefixes);
                     providers = new BundleResourceProvider[roots.length];
 
                     int index = 0;
                     final BundleResourceCache cache = new BundleResourceCache(bundle);
-                    for(final PathMapping path : roots) {
+                    for (final PathMapping path : roots) {
                         final BundleResourceProvider brp = new BundleResourceProvider(cache, path);
                         providers[index] = brp;
 
@@ -137,33 +137,33 @@ public class Activator implements BundleActivator, BundleListener {
                     bundleResourceProviderMap.put(bundle.getBundleId(), providers);
                 }
             }
-            if ( providers != null ) {
-                for(final BundleResourceProvider provider : providers) {
+            if (providers != null) {
+                for (final BundleResourceProvider provider : providers) {
                     final long id = provider.registerService();
                     log.debug("addBundleResourceProvider: Service ID = {}", id);
                 }
             }
         } catch (final Throwable t) {
             log.error(
-                "activate: Problem while registering bundle resources for bundle "
-                     + bundle.getSymbolicName() + ":" + bundle.getVersion() + " (" + bundle.getBundleId() + ")",
-                t);
+                    "activate: Problem while registering bundle resources for bundle " + bundle.getSymbolicName() + ":"
+                            + bundle.getVersion() + " (" + bundle.getBundleId() + ")",
+                    t);
         }
     }
 
     private void removeBundleResourceProvider(final Bundle bundle) {
         final BundleResourceProvider[] brp;
-        synchronized ( this ) {
+        synchronized (this) {
             brp = bundleResourceProviderMap.remove(bundle.getBundleId());
         }
         if (brp != null) {
             log.debug(
-                "removeBundleResourceProvider: Unregistering resources for bundle {}:{} ({})",
-                new Object[] { bundle.getSymbolicName(), bundle.getVersion(), bundle.getBundleId() });
-            for(final BundleResourceProvider provider : brp) {
+                    "removeBundleResourceProvider: Unregistering resources for bundle {}:{} ({})",
+                    new Object[] {bundle.getSymbolicName(), bundle.getVersion(), bundle.getBundleId()});
+            for (final BundleResourceProvider provider : brp) {
                 try {
                     provider.unregisterService();
-                } catch ( final IllegalStateException ise) {
+                } catch (final IllegalStateException ise) {
                     // might happen on shutdown
                 }
             }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
index 3978805..8997f1a 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResource.java
@@ -1,24 +1,23 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 package org.apache.sling.bundleresource.impl;
 
-import static org.apache.jackrabbit.JcrConstants.NT_FILE;
-import static org.apache.jackrabbit.JcrConstants.NT_FOLDER;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
@@ -35,7 +34,6 @@ import jakarta.json.JsonNumber;
 import jakarta.json.JsonObject;
 import jakarta.json.JsonString;
 import jakarta.json.JsonValue;
-
 import org.apache.sling.api.resource.AbstractResource;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceMetadata;
@@ -45,6 +43,9 @@ import org.apache.sling.api.wrappers.ValueMapDecorator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static org.apache.jackrabbit.JcrConstants.NT_FILE;
+import static org.apache.jackrabbit.JcrConstants.NT_FOLDER;
+
 /** A Resource that wraps a Bundle entry */
 public class BundleResource extends AbstractResource {
 
@@ -68,7 +69,8 @@ public class BundleResource extends AbstractResource {
     private final Map<String, Map<String, Object>> subResources;
 
     @SuppressWarnings("unchecked")
-    public BundleResource(final ResourceResolver resourceResolver,
+    public BundleResource(
+            final ResourceResolver resourceResolver,
             final BundleResourceCache cache,
             final PathMapping mappedPath,
             final String resourcePath,
@@ -98,7 +100,7 @@ public class BundleResource extends AbstractResource {
 
             try {
                 final URL url = this.cache.getEntry(mappedPath.getEntryPath(resourcePath));
-                if ( url != null ) {
+                if (url != null) {
                     metadata.setContentLength(url.openConnection().getContentLength());
                 }
             } catch (final Exception e) {
@@ -107,20 +109,21 @@ public class BundleResource extends AbstractResource {
         }
 
         Map<String, Map<String, Object>> children = null;
-        if ( readProps != null ) {
-            for(final Map.Entry<String, Object> entry : readProps.entrySet()) {
-                if ( entry.getValue() instanceof Map ) {
-                    if ( children == null ) {
+        if (readProps != null) {
+            for (final Map.Entry<String, Object> entry : readProps.entrySet()) {
+                if (entry.getValue() instanceof Map) {
+                    if (children == null) {
                         children = new HashMap<>();
                     }
-                    children.put(entry.getKey(), (Map<String, Object>)entry.getValue());
+                    children.put(entry.getKey(), (Map<String, Object>) entry.getValue());
                 } else {
                     properties.put(entry.getKey(), entry.getValue());
                 }
             }
         }
-        if ( this.mappedPath.getJSONPropertiesExtension() != null ) {
-            String propsPath = mappedPath.getEntryPath(resourcePath.concat(this.mappedPath.getJSONPropertiesExtension()));
+        if (this.mappedPath.getJSONPropertiesExtension() != null) {
+            String propsPath =
+                    mappedPath.getEntryPath(resourcePath.concat(this.mappedPath.getJSONPropertiesExtension()));
             if (propsPath == null && resourcePath.equals(mappedPath.getResourceRoot())) {
                 // SLING-10140 - Handle the special case when the resourceRoot points to a file.
                 //   In that case, the JSONProperties sibling entry may still exist
@@ -133,20 +136,21 @@ public class BundleResource extends AbstractResource {
                     propsPath = entryPath.concat(this.mappedPath.getJSONPropertiesExtension());
                 }
             }
-            if ( propsPath != null ) {
+            if (propsPath != null) {
 
                 try {
                     final URL url = this.cache.getEntry(propsPath);
                     if (url != null) {
-                        final JsonObject obj = Json.createReader(url.openStream()).readObject();
-                        for(final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
+                        final JsonObject obj =
+                                Json.createReader(url.openStream()).readObject();
+                        for (final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
                             final Object value = getValue(entry.getValue(), true);
-                            if ( value != null ) {
-                                if ( value instanceof Map ) {
-                                    if ( children == null ) {
+                            if (value != null) {
+                                if (value instanceof Map) {
+                                    if (children == null) {
                                         children = new HashMap<>();
                                     }
-                                    children.put(entry.getKey(), (Map<String, Object>)value);
+                                    children.put(entry.getKey(), (Map<String, Object>) value);
                                 } else {
                                     properties.put(entry.getKey(), value);
                                 }
@@ -154,8 +158,7 @@ public class BundleResource extends AbstractResource {
                         }
                     }
                 } catch (final IOException ioe) {
-                    log.error(
-                            "getInputStream: Cannot get input stream for " + propsPath, ioe);
+                    log.error("getInputStream: Cannot get input stream for " + propsPath, ioe);
                 }
             }
         }
@@ -166,14 +169,19 @@ public class BundleResource extends AbstractResource {
         Resource result = null;
         Map<String, Map<String, Object>> resources = this.subResources;
         String subPath = null;
-        for(String segment : path.split("/")) {
-            if ( resources != null ) {
+        for (String segment : path.split("/")) {
+            if (resources != null) {
                 subPath = subPath == null ? segment : subPath.concat("/").concat(segment);
                 final Map<String, Object> props = resources.get(segment);
-                if ( props != null ) {
-                    result = new BundleResource(this.resourceResolver, this.cache, this.mappedPath,
-                            this.getPath().concat("/").concat(subPath), props, false);
-                    resources = ((BundleResource)result).subResources;
+                if (props != null) {
+                    result = new BundleResource(
+                            this.resourceResolver,
+                            this.cache,
+                            this.mappedPath,
+                            this.getPath().concat("/").concat(subPath),
+                            props,
+                            false);
+                    resources = ((BundleResource) result).subResources;
                 } else {
                     result = null;
                     break;
@@ -187,33 +195,40 @@ public class BundleResource extends AbstractResource {
     }
 
     private static Object getValue(final JsonValue value, final boolean topLevel) {
-        switch ( value.getValueType() ) {
-            // type NULL -> return null
-            case NULL : return null;
-            // type TRUE or FALSE -> return boolean
-            case FALSE : return false;
-            case TRUE : return true;
-            // type String -> return String
-            case STRING : return ((JsonString)value).getString();
-            // type Number -> return long or double
-            case NUMBER : final JsonNumber num = (JsonNumber)value;
-                          if (num.isIntegral()) {
-                               return num.longValue();
-                          }
-                          return num.doubleValue();
-            // type ARRAY -> return list and call this method for each value
-            case ARRAY : final List<Object> array = new ArrayList<>();
-                         for(final JsonValue x : ((JsonArray)value)) {
-                             array.add(getValue(x, false));
-                         }
-                         return array;
-            // type OBJECT -> return map
-            case OBJECT : final Map<String, Object> map = new HashMap<>();
-                          final JsonObject obj = (JsonObject)value;
-                          for(final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
-                              map.put(entry.getKey(), getValue(entry.getValue(), false));
-                          }
-                          return map;
+        switch (value.getValueType()) {
+                // type NULL -> return null
+            case NULL:
+                return null;
+                // type TRUE or FALSE -> return boolean
+            case FALSE:
+                return false;
+            case TRUE:
+                return true;
+                // type String -> return String
+            case STRING:
+                return ((JsonString) value).getString();
+                // type Number -> return long or double
+            case NUMBER:
+                final JsonNumber num = (JsonNumber) value;
+                if (num.isIntegral()) {
+                    return num.longValue();
+                }
+                return num.doubleValue();
+                // type ARRAY -> return list and call this method for each value
+            case ARRAY:
+                final List<Object> array = new ArrayList<>();
+                for (final JsonValue x : ((JsonArray) value)) {
+                    array.add(getValue(x, false));
+                }
+                return array;
+                // type OBJECT -> return map
+            case OBJECT:
+                final Map<String, Object> map = new HashMap<>();
+                final JsonObject obj = (JsonObject) value;
+                for (final Map.Entry<String, JsonValue> entry : obj.entrySet()) {
+                    map.put(entry.getKey(), getValue(entry.getValue(), false));
+                }
+                return map;
         }
         return null;
     }
@@ -264,8 +279,7 @@ public class BundleResource extends AbstractResource {
 
     @Override
     public String toString() {
-        return getClass().getSimpleName() + ", type=" + getResourceType()
-                + ", path=" + getPath();
+        return getClass().getSimpleName() + ", type=" + getResourceType() + ", path=" + getPath();
     }
 
     // ---------- internal -----------------------------------------------------
@@ -283,8 +297,7 @@ public class BundleResource extends AbstractResource {
                     return url.openStream();
                 }
             } catch (IOException ioe) {
-                log.error(
-                        "getInputStream: Cannot get input stream for " + this, ioe);
+                log.error("getInputStream: Cannot get input stream for " + this, ioe);
             }
         }
 
@@ -295,11 +308,14 @@ public class BundleResource extends AbstractResource {
     private URL getURL() {
         if (resourceUrl == null) {
             final URL url = this.cache.getEntry(mappedPath.getEntryPath(this.path));
-            if ( url != null ) {
+            if (url != null) {
                 try {
-                    resourceUrl = new URL(BundleResourceURLStreamHandler.PROTOCOL, null,
-                            -1, path, new BundleResourceURLStreamHandler(
-                                    cache.getBundle(), mappedPath.getEntryPath(path)));
+                    resourceUrl = new URL(
+                            BundleResourceURLStreamHandler.PROTOCOL,
+                            null,
+                            -1,
+                            path,
+                            new BundleResourceURLStreamHandler(cache.getBundle(), mappedPath.getEntryPath(path)));
                 } catch (MalformedURLException mue) {
                     log.error("getURL: Cannot get URL for " + this, mue);
                 }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java
index 5073911..11e0bd3 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceCache.java
@@ -67,7 +67,7 @@ class BundleResourceCache {
      * a given path to prevent looking for non-existing bundle entries multiple
      * times (value is an empty list).
      */
-    private static final List<String> NOT_FOUND_CHILDREN = Collections.<String> emptyList();
+    private static final List<String> NOT_FOUND_CHILDREN = Collections.<String>emptyList();
 
     /**
      * Single entry cache. This is a synchronized map with a size limit.
@@ -106,10 +106,8 @@ class BundleResourceCache {
         this.bundle = bundle;
 
         // create the limited maps wrapping in synchronized maps
-        this.cache = Collections.synchronizedMap(new BundleResourceMap<String, URL>(
-            CACHE_SIZE));
-        this.listCache = Collections.synchronizedMap(new BundleResourceMap<String, List<String>>(
-            LIST_CACHE_SIZE));
+        this.cache = Collections.synchronizedMap(new BundleResourceMap<String, URL>(CACHE_SIZE));
+        this.listCache = Collections.synchronizedMap(new BundleResourceMap<String, List<String>>(LIST_CACHE_SIZE));
     }
 
     /**
@@ -227,8 +225,7 @@ class BundleResourceCache {
      * {@link #removeEldestEntry(Entry)} method to implement the size limit,
      * which is set in the constructor.
      */
-    private static class BundleResourceMap<K, V> extends
-            LinkedHashMap<String, V> {
+    private static class BundleResourceMap<K, V> extends LinkedHashMap<String, V> {
 
         private static final long serialVersionUID = 7455098291380945276L;
 
@@ -271,5 +268,4 @@ class BundleResourceCache {
             return size() > limit;
         }
     }
-
 }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
index 8038fb3..034ef12 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceIterator.java
@@ -65,14 +65,16 @@ class BundleResourceIterator implements Iterator<Resource> {
      * Creates an instance using the given parent bundle resource.
      */
     BundleResourceIterator(final BundleResource parent) {
-        this(parent.getResourceResolver(),
+        this(
+                parent.getResourceResolver(),
                 parent.getBundle(),
                 parent.getMappedPath(),
                 parent.getPath(),
                 parent.getSubResources());
     }
 
-    BundleResourceIterator(final ResourceResolver resourceResolver,
+    BundleResourceIterator(
+            final ResourceResolver resourceResolver,
             final BundleResourceCache bundle,
             final PathMapping mappedPath,
             final String parentPath,
@@ -93,21 +95,26 @@ class BundleResourceIterator implements Iterator<Resource> {
 
     private Iterator<String> getFilteredEntries(final String parentEntryPath) {
         final Set<String> bundleEntries = new TreeSet<>(cache.getEntryPaths(parentEntryPath));
-        if ( this.mappedPath.getJSONPropertiesExtension() != null ) {
+        if (this.mappedPath.getJSONPropertiesExtension() != null) {
             final Set<String> add = new HashSet<>();
             final Iterator<String> iter = bundleEntries.iterator();
-            while ( iter.hasNext() ) {
+            while (iter.hasNext()) {
                 final String path = iter.next();
-                if ( path.endsWith(this.mappedPath.getJSONPropertiesExtension()) ) {
+                if (path.endsWith(this.mappedPath.getJSONPropertiesExtension())) {
                     iter.remove();
-                    add.add(path.substring(0, path.length() - this.mappedPath.getJSONPropertiesExtension().length()));
+                    add.add(path.substring(
+                            0,
+                            path.length()
+                                    - this.mappedPath
+                                            .getJSONPropertiesExtension()
+                                            .length()));
                 }
             }
             bundleEntries.addAll(add);
-            if ( subResources != null ) {
-                for(final String name : subResources.keySet()) {
+            if (subResources != null) {
+                for (final String name : subResources.keySet()) {
                     final String fullPath = parentEntryPath.concat(name);
-                    if ( !bundleEntries.contains(fullPath) ) {
+                    if (!bundleEntries.contains(fullPath)) {
                         bundleEntries.add(fullPath);
                     } else {
                         subResources.remove(name);
@@ -164,8 +171,11 @@ class BundleResourceIterator implements Iterator<Resource> {
             if (slash < 0 || slash == entry.length() - 1) {
                 log.debug("seek: Using entry {}", entry);
                 final boolean isFolder = entry.endsWith("/");
-                final String entryPath = isFolder ? entry.substring(0, entry.length()-1) : entry;
-                return new BundleResource(resourceResolver, cache, mappedPath,
+                final String entryPath = isFolder ? entry.substring(0, entry.length() - 1) : entry;
+                return new BundleResource(
+                        resourceResolver,
+                        cache,
+                        mappedPath,
                         mappedPath.getResourcePath(entryPath),
                         this.subResources != null ? this.subResources.get(ResourceUtil.getName(entryPath)) : null,
                         isFolder);
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
index b5a838d..5fae749 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceProvider.java
@@ -56,16 +56,17 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
         this.root = root;
     }
 
-    //---------- Service Registration
+    // ---------- Service Registration
 
     long registerService() {
         final Bundle bundle = this.cache.getBundle();
         final Dictionary<String, Object> props = new Hashtable<>();
-        props.put(Constants.SERVICE_DESCRIPTION,
-            "Provider of bundle based resources from bundle " + String.valueOf(bundle.getBundleId()));
+        props.put(
+                Constants.SERVICE_DESCRIPTION,
+                "Provider of bundle based resources from bundle " + String.valueOf(bundle.getBundleId()));
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put(ResourceProvider.PROPERTY_ROOT, this.root.getResourceRoot());
-        props.put(PROP_BUNDLE,bundle.getBundleId());
+        props.put(PROP_BUNDLE, bundle.getBundleId());
 
         // SLING-11649 - If this bundle is not in the {@link Bundle#STARTING}, {@link Bundle#ACTIVE},
         // or {@link Bundle#STOPPING} states or this bundle is a fragment bundle, then this
@@ -82,7 +83,7 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
         if (serviceRegistration != null) {
             try {
                 serviceRegistration.unregister();
-            } catch ( final IllegalStateException ise ) {
+            } catch (final IllegalStateException ise) {
                 // this might happen on shutdown, so ignore
             }
             serviceRegistration = null;
@@ -96,7 +97,8 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
      * bundle of this provider.
      */
     @Override
-    public Resource getResource(final ResolveContext<Object> ctx,
+    public Resource getResource(
+            final ResolveContext<Object> ctx,
             final String resourcePath,
             final ResourceContext resourceContext,
             final Resource parent) {
@@ -116,7 +118,7 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
             // which would then of course be a file
             if (entry == null) {
                 entry = cache.getEntry(entryPath);
-                if ( entry == null && this.root.getJSONPropertiesExtension() != null ) {
+                if (entry == null && this.root.getJSONPropertiesExtension() != null) {
                     entry = cache.getEntry(entryPath + this.root.getJSONPropertiesExtension());
                 }
             }
@@ -126,32 +128,29 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
             if (entry != null) {
                 // check if a JSON props file is directly requested
                 // if so, we deny the access
-                if ( this.root.getJSONPropertiesExtension() == null
-                     || !entryPath.endsWith(this.root.getJSONPropertiesExtension()) ) {
-
-                    return new BundleResource(ctx.getResourceResolver(),
-                            cache,
-                            mappedPath,
-                            resourcePath,
-                            null,
-                            isFolder);
+                if (this.root.getJSONPropertiesExtension() == null
+                        || !entryPath.endsWith(this.root.getJSONPropertiesExtension())) {
+
+                    return new BundleResource(
+                            ctx.getResourceResolver(), cache, mappedPath, resourcePath, null, isFolder);
                 }
             }
 
             // the bundle does not contain the path
             // if JSON is enabled check for any parent
-            if ( this.root.getJSONPropertiesExtension() != null ) {
+            if (this.root.getJSONPropertiesExtension() != null) {
                 String parentPath = ResourceUtil.getParent(resourcePath);
-                while ( parentPath != null ) {
+                while (parentPath != null) {
                     final Resource rsrc = getResource(ctx, parentPath, resourceContext, null);
-                    if (rsrc != null ) {
-                        final Resource childResource = ((BundleResource)rsrc).getChildResource(resourcePath.substring(parentPath.length() + 1));
-                        if ( childResource != null ) {
+                    if (rsrc != null) {
+                        final Resource childResource = ((BundleResource) rsrc)
+                                .getChildResource(resourcePath.substring(parentPath.length() + 1));
+                        if (childResource != null) {
                             return childResource;
                         }
                     }
                     parentPath = ResourceUtil.getParent(parentPath);
-                    if ( parentPath != null && this.getMappedPath(parentPath) == null ) {
+                    if (parentPath != null && this.getMappedPath(parentPath) == null) {
                         parentPath = null;
                     }
                 }
@@ -163,18 +162,17 @@ public class BundleResourceProvider extends ResourceProvider<Object> {
 
     @Override
     public Iterator<Resource> listChildren(final ResolveContext<Object> ctx, final Resource parent) {
-     	if (parent instanceof BundleResource && ((BundleResource)parent).getBundle() == this.cache) {
+        if (parent instanceof BundleResource && ((BundleResource) parent).getBundle() == this.cache) {
             // bundle resources can handle this request directly when the parent
-    		// resource is in the same bundle as this provider.
+            // resource is in the same bundle as this provider.
             return new BundleResourceIterator((BundleResource) parent);
-      	}
+        }
 
         // ensure this provider may have children of the parent
         String parentPath = parent.getPath();
         PathMapping mappedPath = getMappedPath(parentPath);
         if (mappedPath != null) {
-            return new BundleResourceIterator(parent.getResourceResolver(),
-                cache, mappedPath, parentPath, null);
+            return new BundleResourceIterator(parent.getResourceResolver(), cache, mappedPath, parentPath, null);
         }
 
         // the parent resource cannot have children in this provider,
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java
index c121be4..190f435 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLConnection.java
@@ -37,7 +37,7 @@ public class BundleResourceURLConnection extends URLConnection {
     private final Bundle bundle;
 
     private final String bundlePath;
-    
+
     /** The original URLConnection */
     private URLConnection delegatee;
 
@@ -56,8 +56,7 @@ public class BundleResourceURLConnection extends URLConnection {
         if (!connected) {
             URL url = bundle.getEntry(bundlePath);
             if (url == null) {
-                throw new IOException("Cannot find entry " + bundlePath
-                    + " in bundle " + bundle + " for URL " + url);
+                throw new IOException("Cannot find entry " + bundlePath + " in bundle " + bundle + " for URL " + url);
             }
 
             delegatee = url.openConnection();
@@ -108,5 +107,4 @@ public class BundleResourceURLConnection extends URLConnection {
 
         return delegatee.getContentType();
     }
-
 }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java
index a27585a..c9d6e7f 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceURLStreamHandler.java
@@ -30,7 +30,7 @@ class BundleResourceURLStreamHandler extends URLStreamHandler {
     static final String PROTOCOL = "bundle";
 
     private final Bundle bundle;
-    
+
     private final String bundlePath;
 
     BundleResourceURLStreamHandler(Bundle bundle, String bundlePath) {
@@ -41,11 +41,9 @@ class BundleResourceURLStreamHandler extends URLStreamHandler {
     @Override
     protected URLConnection openConnection(URL u) throws IOException {
         if (!PROTOCOL.equals(u.getProtocol())) {
-            throw new IOException("Cannot open connection to " + u
-                + ", wrong protocol");
+            throw new IOException("Cannot open connection to " + u + ", wrong protocol");
         }
 
         return new BundleResourceURLConnection(bundle, bundlePath, u);
     }
-
 }
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
index c9069eb..ecd8073 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/BundleResourceWebConsolePlugin.java
@@ -18,6 +18,12 @@
  */
 package org.apache.sling.bundleresource.impl;
 
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
 import java.io.IOException;
 import java.io.PrintWriter;
 import java.util.ArrayList;
@@ -25,12 +31,6 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 import java.util.List;
 
-import javax.servlet.Servlet;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.sling.spi.resource.provider.ResourceProvider;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -52,7 +52,7 @@ class BundleResourceWebConsolePlugin extends HttpServlet {
 
     private final List<BundleResourceProvider> provider = new ArrayList<>();
 
-    //--------- setup and shutdown
+    // --------- setup and shutdown
 
     private static BundleResourceWebConsolePlugin INSTANCE;
 
@@ -75,12 +75,11 @@ class BundleResourceWebConsolePlugin extends HttpServlet {
     }
 
     // private constructor to force using static setup and shutdown
-    private BundleResourceWebConsolePlugin() {
-    }
+    private BundleResourceWebConsolePlugin() {}
 
     @Override
     protected void doGet(final HttpServletRequest req, final HttpServletResponse res)
-    throws ServletException, IOException {
+            throws ServletException, IOException {
         PrintWriter pw = res.getWriter();
 
         pw.println("<table class='content' cellpadding='0' cellspacing='0' width='100%'>");
@@ -127,14 +126,12 @@ class BundleResourceWebConsolePlugin extends HttpServlet {
 
             pw.println("<tr>");
             pw.println("<td>Entry Cache</td>");
-            pw.printf("<td>Size: %d, Limit: %d</td>%n",
-                cache.getEntryCacheSize(), cache.getEntryCacheMaxSize());
+            pw.printf("<td>Size: %d, Limit: %d</td>%n", cache.getEntryCacheSize(), cache.getEntryCacheMaxSize());
             pw.println("</tr>");
 
             pw.println("<tr>");
             pw.println("<td>List Cache</td>");
-            pw.printf("<td>Size: %d, Limit: %d</td>%n",
-                cache.getListCacheSize(), cache.getListCacheMaxSize());
+            pw.printf("<td>Size: %d, Limit: %d</td>%n", cache.getListCacheSize(), cache.getListCacheMaxSize());
             pw.println("</tr>");
 
             pw.println("</table>");
@@ -144,47 +141,45 @@ class BundleResourceWebConsolePlugin extends HttpServlet {
         }
 
         pw.println("</table>");
-
     }
 
     @SuppressWarnings("rawtypes")
     public void activate(BundleContext context) {
-        providerTracker = new ServiceTracker<ResourceProvider, ResourceProvider>(context,
-            ResourceProvider.class.getName(), null) {
-
-            @Override
-            public ResourceProvider addingService(final ServiceReference<ResourceProvider> reference) {
-                ResourceProvider service = null;
-                if ( reference.getProperty(BundleResourceProvider.PROP_BUNDLE) != null ) {
-                    service = super.addingService(reference);
-                    if (service instanceof BundleResourceProvider) {
-                        provider.add((BundleResourceProvider) service);
+        providerTracker =
+                new ServiceTracker<ResourceProvider, ResourceProvider>(
+                        context, ResourceProvider.class.getName(), null) {
+
+                    @Override
+                    public ResourceProvider addingService(final ServiceReference<ResourceProvider> reference) {
+                        ResourceProvider service = null;
+                        if (reference.getProperty(BundleResourceProvider.PROP_BUNDLE) != null) {
+                            service = super.addingService(reference);
+                            if (service instanceof BundleResourceProvider) {
+                                provider.add((BundleResourceProvider) service);
+                            }
+                        }
+                        return service;
                     }
-                }
-                return service;
-            }
 
-            @Override
-            public void removedService(final ServiceReference<ResourceProvider> reference,
-                    final ResourceProvider service) {
-                if (service instanceof BundleResourceProvider) {
-                    provider.remove(service);
-                }
-                super.removedService(reference, service);
-            }
-        };
+                    @Override
+                    public void removedService(
+                            final ServiceReference<ResourceProvider> reference, final ResourceProvider service) {
+                        if (service instanceof BundleResourceProvider) {
+                            provider.remove(service);
+                        }
+                        super.removedService(reference, service);
+                    }
+                };
         providerTracker.open();
 
         Dictionary<String, Object> props = new Hashtable<>();
-        props.put(Constants.SERVICE_DESCRIPTION,
-            "Web Console Plugin for Bundle Resource Providers");
+        props.put(Constants.SERVICE_DESCRIPTION, "Web Console Plugin for Bundle Resource Providers");
         props.put(Constants.SERVICE_VENDOR, "The Apache Software Foundation");
         props.put("felix.webconsole.label", LABEL);
         props.put("felix.webconsole.title", "Bundle Resource Provider");
         props.put("felix.webconsole.category", "Sling");
 
-        serviceRegistration = context.registerService(
-            Servlet.class, this, props);
+        serviceRegistration = context.registerService(Servlet.class, this, props);
     }
 
     public void deactivate() {
diff --git a/src/main/java/org/apache/sling/bundleresource/impl/PathMapping.java b/src/main/java/org/apache/sling/bundleresource/impl/PathMapping.java
index c79e049..e1ee6ff 100644
--- a/src/main/java/org/apache/sling/bundleresource/impl/PathMapping.java
+++ b/src/main/java/org/apache/sling/bundleresource/impl/PathMapping.java
@@ -53,9 +53,7 @@ class PathMapping {
         return prefixList.toArray(new PathMapping[prefixList.size()]);
     }
 
-
-    static PathMapping create(final String configPath,
-            final String expandDirective) {
+    static PathMapping create(final String configPath, final String expandDirective) {
         String resourceRoot;
         String entryRoot;
         int prefixSep = configPath.indexOf(prefixSeparatorChar);
@@ -69,9 +67,7 @@ class PathMapping {
         return new PathMapping(resourceRoot, entryRoot, expandDirective);
     }
 
-    PathMapping(final String resourceRoot,
-            final String entryRoot,
-            final String expandDirective) {
+    PathMapping(final String resourceRoot, final String entryRoot, final String expandDirective) {
         this.resourceRoot = ensureNoTrailingSlash(resourceRoot);
         this.resourceRootPrefix = ensureTrailingSlash(resourceRoot);
         this.entryRoot = ensureLeadingSlash(ensureNoTrailingSlash(entryRoot));
@@ -84,8 +80,7 @@ class PathMapping {
     }
 
     boolean isChild(final String resourcePath) {
-        return resourcePath.startsWith(resourceRootPrefix)
-            || resourcePath.equals(resourceRoot);
+        return resourcePath.startsWith(resourceRootPrefix) || resourcePath.equals(resourceRoot);
     }
 
     String getEntryPath(final String resourcePath) {
@@ -103,12 +98,12 @@ class PathMapping {
     }
 
     String getResourcePath(final String entryPath) {
-        if ( entryRootPrefix == null ) {
+        if (entryRootPrefix == null) {
             return entryPath;
         }
-        if ( entryPath.startsWith(entryRootPrefix) ) {
+        if (entryPath.startsWith(entryRootPrefix)) {
             return resourceRootPrefix.concat(entryPath.substring(entryRootPrefix.length()));
-        } else if ( entryPath.equals(entryRoot)) {
+        } else if (entryPath.equals(entryRoot)) {
             return resourceRoot;
         }
         return null;
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
index 9b8ee72..56454bd 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceProviderTest.java
@@ -18,10 +18,6 @@
  */
 package org.apache.sling.bundleresource.impl;
 
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringWriter;
@@ -34,7 +30,6 @@ import java.util.Map;
 
 import jakarta.json.Json;
 import jakarta.json.stream.JsonGenerator;
-
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ResourceResolver;
 import org.apache.sling.bundleresource.impl.url.ResourceURLStreamHandler;
@@ -46,6 +41,10 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.osgi.framework.Bundle;
 
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class BundleResourceProviderTest {
 
     Bundle getBundle() {
@@ -55,7 +54,6 @@ public class BundleResourceProviderTest {
         return bundle;
     }
 
-
     void addContent(Bundle bundle, String path, Map<String, Object> content) throws IOException {
         final URL url = new URL("resource:" + path);
 
@@ -64,7 +62,8 @@ public class BundleResourceProviderTest {
     }
 
     void finishContent(Bundle bundle) {
-        for(final Map.Entry<String, List<String>> entry : ResourceURLStreamHandler.getParentChildRelationship().entrySet()) {
+        for (final Map.Entry<String, List<String>> entry :
+                ResourceURLStreamHandler.getParentChildRelationship().entrySet()) {
             when(bundle.getEntryPaths(entry.getKey())).thenReturn(Collections.enumeration(entry.getValue()));
         }
     }
@@ -78,7 +77,7 @@ public class BundleResourceProviderTest {
 
     String getContent(final Resource rsrc) throws IOException {
         final InputStream is = rsrc.adaptTo(InputStream.class);
-        if ( is == null ) {
+        if (is == null) {
             return null;
         }
         final byte[] buffer = new byte[20];
@@ -88,8 +87,8 @@ public class BundleResourceProviderTest {
 
     List<String> getChildren(final Iterator<Resource> i) {
         final List<String> list = new ArrayList<>();
-        if ( i != null ) {
-            while ( i.hasNext() ) {
+        if (i != null) {
+            while (i.hasNext()) {
                 list.add(i.next().getPath());
             }
         }
@@ -97,7 +96,8 @@ public class BundleResourceProviderTest {
     }
 
     @SuppressWarnings("unchecked")
-    void assertContent(final BundleResourceProvider provider, final String path, final String content) throws IOException {
+    void assertContent(final BundleResourceProvider provider, final String path, final String content)
+            throws IOException {
         final Resource rsrc = provider.getResource(mock(ResolveContext.class), path, mock(ResourceContext.class), null);
         assertNotNull(rsrc);
         assertEquals(content, getContent(rsrc));
@@ -114,27 +114,33 @@ public class BundleResourceProviderTest {
     }
 
     @SuppressWarnings("unchecked")
-    @Test public void testFileResource() throws IOException {
+    @Test
+    public void testFileResource() throws IOException {
         final Bundle bundle = getBundle();
         addContent(bundle, "/libs/foo/test.json", "HELLOWORLD");
 
         final PathMapping path = new PathMapping("/libs/foo", null, null);
 
         final BundleResourceProvider provider = new BundleResourceProvider(new BundleResourceCache(bundle), path);
-        assertNotNull(provider.getResource(mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
-        assertNull(provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null));
+        assertNotNull(provider.getResource(
+                mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
+        assertNull(
+                provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null));
     }
 
     @SuppressWarnings("unchecked")
-    @Test public void testJSONResource() throws IOException {
+    @Test
+    public void testJSONResource() throws IOException {
         final Bundle bundle = getBundle();
-        addContent(bundle, "/libs/foo/test.json", Collections.singletonMap("test", (Object)"foo"));
+        addContent(bundle, "/libs/foo/test.json", Collections.singletonMap("test", (Object) "foo"));
 
         final PathMapping path = new PathMapping("/libs/foo", null, "json");
 
         final BundleResourceProvider provider = new BundleResourceProvider(new BundleResourceCache(bundle), path);
-        assertNull(provider.getResource(mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
-        final Resource rsrc = provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null);
+        assertNull(provider.getResource(
+                mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
+        final Resource rsrc =
+                provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null);
         assertNotNull(rsrc);
         assertNull(rsrc.adaptTo(InputStream.class));
         assertNull(rsrc.adaptTo(URL.class));
@@ -143,16 +149,19 @@ public class BundleResourceProviderTest {
     }
 
     @SuppressWarnings("unchecked")
-    @Test public void testFileAndJSONResource() throws IOException {
+    @Test
+    public void testFileAndJSONResource() throws IOException {
         final Bundle bundle = getBundle();
         addContent(bundle, "/libs/foo/test", "HELLOWORLD");
-        addContent(bundle, "/libs/foo/test.json", Collections.singletonMap("test", (Object)"foo"));
+        addContent(bundle, "/libs/foo/test.json", Collections.singletonMap("test", (Object) "foo"));
 
         final PathMapping path = new PathMapping("/libs/foo", null, "json");
 
         final BundleResourceProvider provider = new BundleResourceProvider(new BundleResourceCache(bundle), path);
-        assertNull(provider.getResource(mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
-        final Resource rsrc = provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null);
+        assertNull(provider.getResource(
+                mock(ResolveContext.class), "/libs/foo/test.json", mock(ResourceContext.class), null));
+        final Resource rsrc =
+                provider.getResource(mock(ResolveContext.class), "/libs/foo/test", mock(ResourceContext.class), null);
         assertNotNull(rsrc);
         assertNotNull(rsrc.adaptTo(InputStream.class));
         assertNotNull(rsrc.adaptTo(URL.class));
@@ -176,13 +185,16 @@ public class BundleResourceProviderTest {
         addContent(bundle, prefix + "/libs/foo/test", "test");
         addContent(bundle, prefix + "/libs/foo/test/x", "X");
         addContent(bundle, prefix + "/libs/foo/test/y", "Y");
-        addContent(bundle, prefix + "/libs/foo/test/z.json", Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object)"rtz"));
-        addContent(bundle, prefix + "/libs/foo/test.json", Collections.singletonMap("test", (Object)"foo"));
+        addContent(
+                bundle,
+                prefix + "/libs/foo/test/z.json",
+                Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "rtz"));
+        addContent(bundle, prefix + "/libs/foo/test.json", Collections.singletonMap("test", (Object) "foo"));
 
         finishContent(bundle);
 
         final PathMapping path;
-        if ( prefix.length() == 0 ) {
+        if (prefix.length() == 0) {
             path = new PathMapping("/libs/foo", null, "json");
         } else {
             path = new PathMapping("/libs/foo", prefix + "/libs/foo", "json");
@@ -197,7 +209,8 @@ public class BundleResourceProviderTest {
         assertContent(provider, "/libs/foo/test/y", "Y");
         assertContent(provider, "/libs/foo/test/z", null);
 
-        Resource rsrc = provider.getResource(mock(ResolveContext.class), "/libs/foo", mock(ResourceContext.class), null);
+        Resource rsrc =
+                provider.getResource(mock(ResolveContext.class), "/libs/foo", mock(ResourceContext.class), null);
         assertNotNull(rsrc);
 
         List<String> rsrcChildren = getChildren(provider.listChildren(mock(ResolveContext.class), rsrc));
@@ -216,7 +229,8 @@ public class BundleResourceProviderTest {
         assertTrue(rsrcChildren.contains("/libs/foo/test/z"));
     }
 
-    @Test public void testTreeWithDeepJSON() throws IOException {
+    @Test
+    public void testTreeWithDeepJSON() throws IOException {
         testTreeWithDeepJSON("");
         testTreeWithDeepJSON("/SLING-INF");
     }
@@ -269,13 +283,16 @@ public class BundleResourceProviderTest {
         addContent(bundle, prefix + "/libs/foo/test", "test");
         addContent(bundle, prefix + "/libs/foo/test/x", "X");
         addContent(bundle, prefix + "/libs/foo/test/y", "Y");
-        addContent(bundle, prefix + "/libs/foo/test/z.json", Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object)"rtz"));
-        addContent(bundle, prefix + "/libs/foo/test.json", Collections.singletonMap("test", (Object)"foo"));
+        addContent(
+                bundle,
+                prefix + "/libs/foo/test/z.json",
+                Collections.singletonMap(ResourceResolver.PROPERTY_RESOURCE_TYPE, (Object) "rtz"));
+        addContent(bundle, prefix + "/libs/foo/test.json", Collections.singletonMap("test", (Object) "foo"));
 
         finishContent(bundle);
 
         final PathMapping path;
-        if ( prefix.length() == 0 ) {
+        if (prefix.length() == 0) {
             path = new PathMapping("/libs/foo", null, "json");
         } else {
             path = new PathMapping("/libs/foo", prefix + "/libs/foo", "json");
@@ -290,7 +307,8 @@ public class BundleResourceProviderTest {
         assertContent(provider, "/libs/foo/test/y", "Y");
         assertContent(provider, "/libs/foo/test/z", null);
 
-        Resource rsrc = provider.getResource(mock(ResolveContext.class), "/libs/foo", mock(ResourceContext.class), null);
+        Resource rsrc =
+                provider.getResource(mock(ResolveContext.class), "/libs/foo", mock(ResourceContext.class), null);
         assertNotNull(rsrc);
 
         List<String> rsrcChildren = getChildren(provider.listChildren(mock(ResolveContext.class), rsrc));
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
index 8ea858f..8300df8 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/BundleResourceTest.java
@@ -18,11 +18,6 @@
  */
 package org.apache.sling.bundleresource.impl;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -39,6 +34,11 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 import org.osgi.framework.Bundle;
 
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 public class BundleResourceTest {
 
     BundleResourceCache getBundleResourceCache() {
@@ -79,19 +79,20 @@ public class BundleResourceTest {
     public void testFileResource() throws MalformedURLException {
         final BundleResourceCache cache = getBundleResourceCache();
         when(cache.getEntry("/libs/foo/test.json")).thenReturn(new URL("file:/libs/foo/test.json"));
-        final BundleResource rsrc = new BundleResource(null, cache,
-                new PathMapping("/libs/foo", null, null), "/libs/foo/test.json", null, false);
+        final BundleResource rsrc = new BundleResource(
+                null, cache, new PathMapping("/libs/foo", null, null), "/libs/foo/test.json", null, false);
         assertEquals(JcrConstants.NT_FILE, rsrc.getResourceType());
         assertNull(rsrc.getResourceSuperType());
         final ValueMap vm = rsrc.getValueMap();
         assertEquals(JcrConstants.NT_FILE, vm.get(ResourceResolver.PROPERTY_RESOURCE_TYPE, String.class));
     }
 
-    @Test public void testJSONResource() throws IOException {
+    @Test
+    public void testJSONResource() throws IOException {
         final BundleResourceCache cache = getBundleResourceCache();
-        addContent(cache, "/libs/foo/test.json", Collections.singletonMap("test", (Object)"foo"));
-        final BundleResource rsrc = new BundleResource(null, cache,
-                new PathMapping("/libs/foo", null, "json"), "/libs/foo/test", null, false);
+        addContent(cache, "/libs/foo/test.json", Collections.singletonMap("test", (Object) "foo"));
+        final BundleResource rsrc = new BundleResource(
+                null, cache, new PathMapping("/libs/foo", null, "json"), "/libs/foo/test", null, false);
         assertEquals(JcrConstants.NT_FILE, rsrc.getResourceType());
         assertNull(rsrc.getResourceSuperType());
         final ValueMap vm = rsrc.getValueMap();
@@ -103,12 +104,18 @@ public class BundleResourceTest {
      * SLING-10140 - Verify that when the resourceRoot is a mapped file, that the sibling entry with the
      *  JSONPropertiesExtension is loaded
      */
-    @Test public void testJSONResourceForMappedFile() throws IOException {
+    @Test
+    public void testJSONResourceForMappedFile() throws IOException {
         final BundleResourceCache cache = getBundleResourceCache();
         addContent(cache, "/SLING_INF/libs/foo/test.txt", "Hello Text");
-        addContent(cache, "/SLING-INF/libs/foo/test.txt.json", Collections.singletonMap("test", (Object)"foo"));
-        final BundleResource rsrc = new BundleResource(null, cache,
-                new PathMapping("/libs/foo/test.txt", "/SLING-INF/libs/foo/test.txt", "json"), "/libs/foo/test.txt", null, false);
+        addContent(cache, "/SLING-INF/libs/foo/test.txt.json", Collections.singletonMap("test", (Object) "foo"));
+        final BundleResource rsrc = new BundleResource(
+                null,
+                cache,
+                new PathMapping("/libs/foo/test.txt", "/SLING-INF/libs/foo/test.txt", "json"),
+                "/libs/foo/test.txt",
+                null,
+                false);
         assertEquals(JcrConstants.NT_FILE, rsrc.getResourceType());
         assertNull(rsrc.getResourceSuperType());
         final ValueMap vm = rsrc.getValueMap();
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java b/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
index 2148a85..5abf2c7 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/NoBundleContextTest.java
@@ -18,12 +18,6 @@
  */
 package org.apache.sling.bundleresource.impl;
 
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
 import java.io.IOException;
 import java.util.Dictionary;
 
@@ -35,6 +29,12 @@ import org.osgi.framework.Constants;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
 
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
 /**
  * SLING-11649 - verify check for null BundleContext while registering bundle resources
  */
@@ -68,8 +68,8 @@ public class NoBundleContextTest {
 
         final PathMapping path = new PathMapping("/libs/foo", null, null);
         final BundleResourceProvider provider = new BundleResourceProvider(new BundleResourceCache(bundle), path);
-        when(bc.registerService(eq(ResourceProvider.class), eq(provider), any(Dictionary.class))).thenReturn(svcReg);
+        when(bc.registerService(eq(ResourceProvider.class), eq(provider), any(Dictionary.class)))
+                .thenReturn(svcReg);
         assertEquals(123L, provider.registerService());
     }
-
 }
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java b/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
index 60afb92..1124025 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/PathMappingTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.sling.bundleresource.impl;
 
-
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -37,7 +36,8 @@ public class PathMappingTest {
         assertNull(paths[0].getJSONPropertiesExtension());
     }
 
-    @Test public void testSimpleRootWithJSON() {
+    @Test
+    public void testSimpleRootWithJSON() {
         final PathMapping[] paths = PathMapping.getRoots("/libs/foo;" + PathMapping.DIR_JSON + ":=json");
         assertEquals(1, paths.length);
         assertNull(paths[0].getEntryRoot());
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLConnection.java b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLConnection.java
index 62b5ec2..6a23564 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLConnection.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLConnection.java
@@ -35,7 +35,7 @@ public class ResourceURLConnection extends URLConnection {
 
     @Override
     public void connect() throws IOException {
-        if ( contents == null ) {
+        if (contents == null) {
             throw new IOException("404");
         }
     }
@@ -49,4 +49,4 @@ public class ResourceURLConnection extends URLConnection {
     public InputStream getInputStream() throws IOException {
         return new ByteArrayInputStream(this.contents.getBytes("UTF-8"));
     }
-}
\ No newline at end of file
+}
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
index 0cb79ab..1462617 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandler.java
@@ -32,7 +32,6 @@ import jakarta.json.Json;
 import jakarta.json.JsonArrayBuilder;
 import jakarta.json.JsonObjectBuilder;
 import jakarta.json.JsonStructure;
-
 import org.apache.sling.api.resource.ResourceUtil;
 
 public class ResourceURLStreamHandler extends URLStreamHandler {
@@ -45,14 +44,14 @@ public class ResourceURLStreamHandler extends URLStreamHandler {
         contents.put(path, c);
         final String parent = ResourceUtil.getParent(path).concat("/");
         List<String> children = parentChild.get(parent);
-        if ( children == null ) {
+        if (children == null) {
             children = new ArrayList<>();
             parentChild.put(parent, children);
         }
         children.add(path);
     }
 
-    public static  Map<String, List<String>> getParentChildRelationship() {
+    public static Map<String, List<String>> getParentChildRelationship() {
         return parentChild;
     }
 
@@ -67,7 +66,6 @@ public class ResourceURLStreamHandler extends URLStreamHandler {
         parentChild.clear();
     }
 
-
     @Override
     protected URLConnection openConnection(URL url) throws IOException {
         final ResourceURLConnection conn = new ResourceURLConnection(url, contents.get(url.getPath()));
@@ -76,43 +74,42 @@ public class ResourceURLStreamHandler extends URLStreamHandler {
     }
 
     private static JsonStructure build(final Object value) {
-        if ( value instanceof List ) {
+        if (value instanceof List) {
             @SuppressWarnings("unchecked")
-            final List<Object> list = (List<Object>)value;
+            final List<Object> list = (List<Object>) value;
             final JsonArrayBuilder builder = Json.createArrayBuilder();
-            for(final Object obj : list) {
-                if ( obj instanceof String ) {
+            for (final Object obj : list) {
+                if (obj instanceof String) {
                     builder.add(obj.toString());
-                } else if ( obj instanceof Long ) {
-                    builder.add((Long)obj);
-                } else if ( obj instanceof Double ) {
-                    builder.add((Double)obj);
-                } else if (obj instanceof Boolean ) {
-                    builder.add((Boolean)obj);
-                } else if ( obj instanceof Map ) {
+                } else if (obj instanceof Long) {
+                    builder.add((Long) obj);
+                } else if (obj instanceof Double) {
+                    builder.add((Double) obj);
+                } else if (obj instanceof Boolean) {
+                    builder.add((Boolean) obj);
+                } else if (obj instanceof Map) {
                     builder.add(build(obj));
-                } else if ( obj instanceof List ) {
+                } else if (obj instanceof List) {
                     builder.add(build(obj));
                 }
-
             }
             return builder.build();
-        } else if ( value instanceof Map ) {
+        } else if (value instanceof Map) {
             @SuppressWarnings("unchecked")
-            final Map<String, Object> map = (Map<String, Object>)value;
+            final Map<String, Object> map = (Map<String, Object>) value;
             final JsonObjectBuilder builder = Json.createObjectBuilder();
-            for(final Map.Entry<String, Object> entry : map.entrySet()) {
-                if ( entry.getValue() instanceof String ) {
+            for (final Map.Entry<String, Object> entry : map.entrySet()) {
+                if (entry.getValue() instanceof String) {
                     builder.add(entry.getKey(), entry.getValue().toString());
-                } else if ( entry.getValue() instanceof Long ) {
-                    builder.add(entry.getKey(), (Long)entry.getValue());
-                } else if ( entry.getValue() instanceof Double ) {
-                    builder.add(entry.getKey(), (Double)entry.getValue());
-                } else if ( entry.getValue() instanceof Boolean ) {
-                    builder.add(entry.getKey(), (Boolean)entry.getValue());
-                } else if ( entry.getValue() instanceof Map ) {
+                } else if (entry.getValue() instanceof Long) {
+                    builder.add(entry.getKey(), (Long) entry.getValue());
+                } else if (entry.getValue() instanceof Double) {
+                    builder.add(entry.getKey(), (Double) entry.getValue());
+                } else if (entry.getValue() instanceof Boolean) {
+                    builder.add(entry.getKey(), (Boolean) entry.getValue());
+                } else if (entry.getValue() instanceof Map) {
                     builder.add(entry.getKey(), build(entry.getValue()));
-                } else if ( entry.getValue() instanceof List ) {
+                } else if (entry.getValue() instanceof List) {
                     builder.add(entry.getKey(), build(entry.getValue()));
                 }
             }
@@ -121,4 +118,3 @@ public class ResourceURLStreamHandler extends URLStreamHandler {
         return null;
     }
 }
-
diff --git a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandlerFactory.java b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandlerFactory.java
index b501d4f..abd3ef2 100644
--- a/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandlerFactory.java
+++ b/src/test/java/org/apache/sling/bundleresource/impl/url/ResourceURLStreamHandlerFactory.java
@@ -25,6 +25,7 @@ import java.net.URLStreamHandlerFactory;
 public class ResourceURLStreamHandlerFactory implements URLStreamHandlerFactory {
 
     private static volatile boolean init = false;
+
     @Override
     public URLStreamHandler createURLStreamHandler(String protocol) {
         if ("resource".equals(protocol)) {
@@ -35,11 +36,9 @@ public class ResourceURLStreamHandlerFactory implements URLStreamHandlerFactory
     }
 
     public static void init() {
-        if ( !init ) {
+        if (!init) {
             URL.setURLStreamHandlerFactory(new ResourceURLStreamHandlerFactory());
             init = true;
         }
     }
-
 }
-


(sling-org-apache-sling-bundleresource-impl) 01/02: SLING-12694 Update to Parent 62

Posted by ss...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

sseifert pushed a commit to branch feature/SLING-12694-parent-62
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-bundleresource-impl.git

commit 74c06eca2ebbb0bdade72870da814efda3385afc
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Wed Mar 5 18:05:02 2025 +0100

    SLING-12694 Update to Parent 62
---
 .sling-module.json | 5 +++++
 pom.xml            | 3 ++-
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/.sling-module.json b/.sling-module.json
new file mode 100644
index 0000000..cfad4d2
--- /dev/null
+++ b/.sling-module.json
@@ -0,0 +1,5 @@
+{
+  "jenkins": {
+    "jdks": [17, 21]
+  }
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index e5a2ff8..281631e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.sling</groupId>
         <artifactId>sling-bundle-parent</artifactId>
-        <version>52</version>
+        <version>62</version>
         <relativePath />
     </parent>
 
@@ -36,6 +36,7 @@
     </description>
 
     <properties>
+        <sling.java.version>11</sling.java.version>
         <project.build.outputTimestamp>2021-04-23T16:34:16Z</project.build.outputTimestamp>
     </properties>