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

jungm pushed a commit to branch xbean-4.30-SNAPSHOT
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/xbean-4.30-SNAPSHOT by this 
push:
     new 5080bac1e1 Don't store complex class type in ServiceInfo
5080bac1e1 is described below

commit 5080bac1e1e609fc94d1ae04bdbc699069abba30
Author: Markus Jung <[email protected]>
AuthorDate: Mon Jan 5 14:21:14 2026 +0100

    Don't store complex class type in ServiceInfo
    
    documented in OpenEjbConfigurationValidationTest
---
 .../openejb/assembler/classic/Assembler.java       | 39 ++++++++++++++++++----
 .../openejb/assembler/classic/ServiceInfo.java     |  2 +-
 .../openejb/config/ConfigurationFactory.java       | 35 +------------------
 3 files changed, 35 insertions(+), 41 deletions(-)

diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
index 7a38e87f2a..5be7d978db 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
@@ -228,6 +228,7 @@ import java.lang.instrument.ClassFileTransformer;
 import java.lang.instrument.Instrumentation;
 import java.lang.management.ManagementFactory;
 import java.lang.management.ThreadInfo;
+import java.lang.reflect.Array;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.lang.reflect.Proxy;
@@ -1411,11 +1412,7 @@ public class Assembler extends AssemblerTool implements 
org.apache.openejb.spi.A
                     query.put("constructor", Join.join(",", 
si.constructorArgs));
                 }
                 if (si.constructorArgTypes != null && 
!si.constructorArgTypes.isEmpty()) {
-                    String rawConstructorArgTypes = 
si.constructorArgTypes.stream()
-                            .map(Class::getName)
-                            .collect(Collectors.joining(","));
-
-                    query.put("constructor-types", Join.join(",", 
rawConstructorArgTypes));
+                    query.put("constructor-types", Join.join(",", 
si.constructorArgTypes));
                 }
                 appInfo.properties.put(si.id, "new://Service?" + 
URISupport.createQueryString(query));
                 if (si.properties != null) {
@@ -3759,7 +3756,16 @@ public class Assembler extends AssemblerTool implements 
org.apache.openejb.spi.A
 
     public static ObjectRecipe prepareRecipe(final ServiceInfo info) {
         final String[] constructorArgs = info.constructorArgs.toArray(new 
String[0]);
-        final Class[] constructorArgTypes = 
info.constructorArgTypes.toArray(new Class[0]);
+        final Class[] constructorArgTypes = info.constructorArgTypes.stream()
+                .map(it -> {
+                    try {
+                        return getClassForType(it);
+                    } catch (final ClassNotFoundException e) {
+                        throw new OpenEJBRuntimeException(e);
+                    }
+                })
+                .toArray(Class[]::new);
+
         final ObjectRecipe serviceRecipe = new ObjectRecipe(info.className, 
info.factoryMethod,
                 constructorArgs, constructorArgTypes.length > 0 ? 
constructorArgTypes : null); //if empty, treat as not set
         serviceRecipe.allow(Option.CASE_INSENSITIVE_PROPERTIES);
@@ -3818,6 +3824,27 @@ public class Assembler extends AssemblerTool implements 
org.apache.openejb.spi.A
         }
     }
 
+    private static Class<?> getClassForType(String typeName) throws 
ClassNotFoundException {
+        if (typeName.endsWith("[]")) {
+            final String elementType = typeName.substring(0, typeName.length() 
- 2);
+            final Class<?> elementClass = getClassForType(elementType); // 
recursion
+            return Array.newInstance(elementClass, 0).getClass();
+        }
+
+        return switch (typeName) {
+            case "boolean" -> boolean.class;
+            case "byte"    -> byte.class;
+            case "char"    -> char.class;
+            case "short"   -> short.class;
+            case "int"     -> int.class;
+            case "long"    -> long.class;
+            case "float"   -> float.class;
+            case "double"  -> double.class;
+            case "void"    -> void.class;
+            default -> Class.forName(typeName); // regular case
+        };
+    }
+
     private static class PersistenceClassLoaderHandlerImpl implements 
PersistenceClassLoaderHandler {
         private static final AtomicBoolean logged = new AtomicBoolean(false);
 
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceInfo.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceInfo.java
index 619ab0822c..cde31d962f 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceInfo.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/ServiceInfo.java
@@ -35,7 +35,7 @@ public class ServiceInfo extends InfoObject {
     public String classpathAPI;
     public Properties properties;
     public final List<String> constructorArgs = new ArrayList<>();
-    public final List<Class<?>> constructorArgTypes = new ArrayList<>();
+    public final List<String> constructorArgTypes = new ArrayList<>();
     public Properties unsetProperties; // keep it in the model to be able to 
investigate it dumping Infos
 
     /**
diff --git 
a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
 
b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
index 4f92eb779d..dd3383cc8e 100644
--- 
a/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
+++ 
b/container/openejb-core/src/main/java/org/apache/openejb/config/ConfigurationFactory.java
@@ -1293,7 +1293,7 @@ public class ConfigurationFactory implements 
OpenEjbConfigurationFactory {
             info.id = service.getId();
             info.properties = props;
             info.constructorArgs.addAll(parseList(provider.getConstructor()));
-            
info.constructorArgTypes.addAll(parseConstructorArgTypes(provider));
+            
info.constructorArgTypes.addAll(parseList(provider.getConstructorTypes()));
             if (info instanceof ResourceInfo && service instanceof Resource) {
                 final ResourceInfo ri = ResourceInfo.class.cast(info);
                 final Resource resource = Resource.class.cast(service);
@@ -1609,39 +1609,6 @@ public class ConfigurationFactory implements 
OpenEjbConfigurationFactory {
         return Arrays.asList(raw.split("[ ,]+"));
     }
 
-    private List<Class<?>> parseConstructorArgTypes(final ServiceProvider 
service) {
-        return parseList(service.getConstructorTypes()).stream()
-                .map(it -> {
-                    try {
-                        return getClassForType(it);
-                    } catch (final ClassNotFoundException e) {
-                        throw new OpenEJBRuntimeException(e);
-                    }
-                })
-                .collect(Collectors.toUnmodifiableList());
-    }
-
-    private Class<?> getClassForType(String typeName) throws 
ClassNotFoundException {
-        if (typeName.endsWith("[]")) {
-            final String elementType = typeName.substring(0, typeName.length() 
- 2);
-            final Class<?> elementClass = getClassForType(elementType); // 
recursion
-            return Array.newInstance(elementClass, 0).getClass();
-        }
-
-        return switch (typeName) {
-            case "boolean" -> boolean.class;
-            case "byte"    -> byte.class;
-            case "char"    -> char.class;
-            case "short"   -> short.class;
-            case "int"     -> int.class;
-            case "long"    -> long.class;
-            case "float"   -> float.class;
-            case "double"  -> double.class;
-            case "void"    -> void.class;
-            default -> Class.forName(typeName); // regular case
-        };
-    }
-
     protected List<String> getResourceIds() {
         return getResourceIds(null);
     }

Reply via email to