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

kwin pushed a commit to branch master
in repository 
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git


The following commit(s) were added to refs/heads/master by this push:
     new 17b7465  SLING-13092 Emit service properties containing arrays properly
17b7465 is described below

commit 17b7465bd931b552bab104be7081d16b37b7916c
Author: Konrad Windszus <[email protected]>
AuthorDate: Mon Feb 2 18:42:19 2026 +0100

    SLING-13092 Emit service properties containing arrays properly
    
    Previously the default Java representation of arrays was used which
    doesn't expose the item's values.
---
 .../models/impl/ModelConfigurationPrinter.java     | 34 ++++++++++++++++++----
 1 file changed, 29 insertions(+), 5 deletions(-)

diff --git 
a/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java 
b/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
index b804530..0f241b5 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelConfigurationPrinter.java
@@ -19,6 +19,7 @@
 package org.apache.sling.models.impl;
 
 import java.io.PrintWriter;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
@@ -54,6 +55,27 @@ public class ModelConfigurationPrinter {
         this.adapterImplementations = adapterImplementations;
     }
 
+    /**
+     * Converts an arbitrary property value to its string representation.
+     * Properly handles arrays, nulls, and various types.
+     *
+     * @param value the property value to convert (can be null, array, or any 
object)
+     * @return a string representation of the value, or "null" if value is null
+     */
+    private String propertyToString(Object value) {
+        if (value == null) {
+            return "null";
+        }
+
+        // Handle arrays
+        if (value.getClass().isArray()) {
+            return Arrays.toString((Object[]) value);
+        }
+
+        // Handle all other types
+        return value.toString();
+    }
+
     public void printConfiguration(PrintWriter printWriter) {
 
         // injectors
@@ -153,15 +175,17 @@ public class ModelConfigurationPrinter {
                     
bundleContext.getServiceReferences(Servlet.class.getName(), 
EXPORT_SERVLET_FILTER);
             if (servlets != null) {
                 for (ServiceReference ref : servlets) {
-                    
printWriter.print(ref.getProperty(ModelPackageBundleListener.PROP_EXPORTER_SERVLET_CLASS));
+                    printWriter.print(
+                            
propertyToString(ref.getProperty(ModelPackageBundleListener.PROP_EXPORTER_SERVLET_CLASS)));
                     printWriter.print(" exports '");
-                    
printWriter.print(ref.getProperty("sling.servlet.resourceTypes"));
+                    
printWriter.print(propertyToString(ref.getProperty("sling.servlet.resourceTypes")));
                     printWriter.print("' with selector '");
-                    
printWriter.print(ref.getProperty("sling.servlet.selectors"));
+                    
printWriter.print(propertyToString(ref.getProperty("sling.servlet.selectors")));
                     printWriter.print("' and extension '");
-                    
printWriter.print(ref.getProperty("sling.servlet.extensions"));
+                    
printWriter.print(propertyToString(ref.getProperty("sling.servlet.extensions")));
                     printWriter.print("' with exporter '");
-                    
printWriter.print(ref.getProperty(ModelPackageBundleListener.PROP_EXPORTER_SERVLET_NAME));
+                    printWriter.print(
+                            
propertyToString(ref.getProperty(ModelPackageBundleListener.PROP_EXPORTER_SERVLET_NAME)));
                     printWriter.println("'");
                 }
             }

Reply via email to