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

robertlazarski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/axis-axis2-java-core.git

commit c9efc0590ddf604fe388f181dfbe2a880c43ce9f
Author: Robert Lazarski <[email protected]>
AuthorDate: Sat Apr 11 16:02:12 2026 -1000

    Apply Gemini review: null safety, ambiguity detection, List<T> test
    
    - Fix potential NPE on SpringBeanName parameter with null value
    - Add overloaded method ambiguity detection with warn log
    - Improve exception handling: ClassNotFoundException/SecurityException
      at debug level, unexpected exceptions at warn level
    - Add List<String> test for generic type mapping (7 tests total)
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../apache/axis2/openapi/OpenApiSpecGenerator.java | 25 ++++++++++++++++-----
 .../apache/axis2/openapi/McpAutoSchemaTest.java    | 26 ++++++++++++++++++++++
 2 files changed, 45 insertions(+), 6 deletions(-)

diff --git 
a/modules/openapi/src/main/java/org/apache/axis2/openapi/OpenApiSpecGenerator.java
 
b/modules/openapi/src/main/java/org/apache/axis2/openapi/OpenApiSpecGenerator.java
index 18d69ae815..49b50d41f0 100644
--- 
a/modules/openapi/src/main/java/org/apache/axis2/openapi/OpenApiSpecGenerator.java
+++ 
b/modules/openapi/src/main/java/org/apache/axis2/openapi/OpenApiSpecGenerator.java
@@ -626,8 +626,10 @@ public class OpenApiSpecGenerator {
             if (serviceClass == null && request != null) {
                 try {
                     String beanName = null;
-                    if (service.getParameter("SpringBeanName") != null) {
-                        beanName = (String) 
service.getParameter("SpringBeanName").getValue();
+                    org.apache.axis2.description.Parameter springBeanParam =
+                            service.getParameter("SpringBeanName");
+                    if (springBeanParam != null && springBeanParam.getValue() 
!= null) {
+                        beanName = (String) springBeanParam.getValue();
                     }
                     if (beanName != null) {
                         jakarta.servlet.ServletContext sc = 
request.getServletContext();
@@ -658,8 +660,14 @@ public class OpenApiSpecGenerator {
             java.lang.reflect.Method targetMethod = null;
             for (java.lang.reflect.Method m : serviceClass.getMethods()) {
                 if (m.getName().equals(operationName) && m.getParameterCount() 
== 1) {
-                    targetMethod = m;
-                    break;
+                    if (targetMethod != null) {
+                        log.warn("[MCP] Ambiguous method '" + operationName
+                                + "' in " + serviceClass.getName()
+                                + " — multiple one-arg overloads, using first 
match");
+                    }
+                    if (targetMethod == null) {
+                        targetMethod = m;
+                    }
                 }
             }
             if (targetMethod == null) return null;
@@ -698,9 +706,14 @@ public class OpenApiSpecGenerator {
             }
 
             return schema;
-        } catch (Exception e) {
+        } catch (ClassNotFoundException | SecurityException e) {
             log.debug("[MCP] Could not auto-generate schema for " + 
service.getName()
-                    + "/" + operationName + ": " + e.getMessage());
+                    + "/" + operationName + ": " + e.getClass().getSimpleName()
+                    + " - " + e.getMessage());
+            return null;
+        } catch (Exception e) {
+            log.warn("[MCP] Unexpected error during auto-schema generation for 
"
+                    + service.getName() + "/" + operationName, e);
             return null;
         }
     }
diff --git 
a/modules/openapi/src/test/java/org/apache/axis2/openapi/McpAutoSchemaTest.java 
b/modules/openapi/src/test/java/org/apache/axis2/openapi/McpAutoSchemaTest.java
index 4f8ba007e9..96da6719d8 100644
--- 
a/modules/openapi/src/test/java/org/apache/axis2/openapi/McpAutoSchemaTest.java
+++ 
b/modules/openapi/src/test/java/org/apache/axis2/openapi/McpAutoSchemaTest.java
@@ -55,6 +55,7 @@ public class McpAutoSchemaTest {
         private double[] values;
         private double[][] matrix;
         private String requestId;
+        private java.util.List<String> tags;
 
         public int getCount() { return count; }
         public void setCount(int count) { this.count = count; }
@@ -72,6 +73,8 @@ public class McpAutoSchemaTest {
         public void setMatrix(double[][] matrix) { this.matrix = matrix; }
         public String getRequestId() { return requestId; }
         public void setRequestId(String requestId) { this.requestId = 
requestId; }
+        public java.util.List<String> getTags() { return tags; }
+        public void setTags(java.util.List<String> tags) { this.tags = tags; }
     }
 
     public static class SampleResponse {
@@ -275,4 +278,27 @@ public class McpAutoSchemaTest {
         assertTrue("isActive() should produce active property", 
props.has("active"));
         assertEquals("boolean", props.get("active").get("type").asText());
     }
+
+    @Test
+    public void testAutoSchemaGenericListType() throws Exception {
+        AxisService service = createServiceWithClass("SampleService",
+                McpAutoSchemaTest.SampleService.class.getName());
+        addOperation(service, "calculate");
+
+        String catalog = generator.generateMcpCatalogJson(null);
+        JsonNode root = jackson.readTree(catalog);
+        JsonNode calcTool = null;
+        for (JsonNode tool : root.get("tools")) {
+            if ("calculate".equals(tool.get("name").asText())) {
+                calcTool = tool;
+                break;
+            }
+        }
+        JsonNode props = calcTool.get("inputSchema").get("properties");
+
+        // List<String> -> array of strings
+        assertTrue("should have tags property", props.has("tags"));
+        assertEquals("array", props.get("tags").get("type").asText());
+        assertEquals("string", 
props.get("tags").get("items").get("type").asText());
+    }
 }

Reply via email to