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

ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/master by this push:
     new d1995a1371 Including all serializable JPA properties to the info 
Actuator's output
d1995a1371 is described below

commit d1995a137129addf7936d4d97dff5c501fb889a1
Author: Francesco Chicchiriccò <[email protected]>
AuthorDate: Tue May 19 12:04:50 2026 +0200

    Including all serializable JPA properties to the info Actuator's output
---
 .../persistence/jpa/dao/JPAPersistenceInfoDAO.java | 53 ++++++++++++++++++++++
 pom.xml                                            |  2 +-
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPersistenceInfoDAO.java
 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPersistenceInfoDAO.java
index 6966ce5208..f304792c50 100644
--- 
a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPersistenceInfoDAO.java
+++ 
b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAPersistenceInfoDAO.java
@@ -19,8 +19,12 @@
 package org.apache.syncope.core.persistence.jpa.dao;
 
 import jakarta.persistence.EntityManagerFactory;
+import java.io.Serializable;
+import java.util.Collection;
 import java.util.LinkedHashMap;
 import java.util.Map;
+import java.util.Set;
+import org.apache.commons.lang3.ClassUtils;
 import org.apache.syncope.core.persistence.api.dao.PersistenceInfoDAO;
 import org.hibernate.Version;
 import org.slf4j.Logger;
@@ -30,6 +34,44 @@ public class JPAPersistenceInfoDAO implements 
PersistenceInfoDAO {
 
     protected static final Logger LOG = 
LoggerFactory.getLogger(PersistenceInfoDAO.class);
 
+    protected static final Set<String> UNSAFE_PROPERTIES = Set.of(
+            "hibernate.connection.datasource",
+            "javax.persistence.nonJtaDataSource",
+            "jakarta.persistence.nonJtaDataSource");
+
+    protected static boolean isJsonSafe(final String key, final Object value) {
+        if (UNSAFE_PROPERTIES.contains(key)) {
+            return false;
+        }
+
+        if (value == null) {
+            return true;
+        }
+        if (ClassUtils.isPrimitiveOrWrapper(value.getClass())) {
+            return true;
+        }
+        if (value instanceof Collection<?> collection) {
+            for (Object e : collection) {
+                if (!isJsonSafe(key, e)) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        if (value instanceof Map<?, ?> map) {
+            for (Map.Entry<?, ?> e : map.entrySet()) {
+                if (!(e.getKey() instanceof String)) {
+                    return false; // JSON object keys must be strings
+                }
+                if (!isJsonSafe((String) e.getKey(), e.getValue())) {
+                    return false;
+                }
+            }
+            return true;
+        }
+        return value instanceof Serializable;
+    }
+
     protected final EntityManagerFactory entityManagerFactory;
 
     public JPAPersistenceInfoDAO(final EntityManagerFactory 
entityManagerFactory) {
@@ -44,6 +86,17 @@ public class JPAPersistenceInfoDAO implements 
PersistenceInfoDAO {
         result.put("version", 
Version.class.getPackage().getImplementationVersion());
         result.put("title", 
Version.class.getPackage().getImplementationTitle());
 
+        Map<String, Object> properties = entityManagerFactory.getProperties();
+        properties.forEach((k, v) -> {
+            if (k.startsWith("hibernate") || 
k.startsWith("jakarta.persistence")) {
+                if (isJsonSafe(k, v)) {
+                    result.put(k, v);
+                } else {
+                    LOG.debug("Value for {} not JSON safe", k);
+                }
+            }
+        });
+
         return result;
     }
 }
diff --git a/pom.xml b/pom.xml
index 5bcf32bddb..ad702d2b3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1905,7 +1905,7 @@ under the License.
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-enforcer-plugin</artifactId>
-        <version>3.6.2</version>
+        <version>3.6.3</version>
         <executions>
           <execution>
             <id>default-cli</id>

Reply via email to