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 f2f7c47f14c3194db364434a87ff9ceb87b8b093
Author: Robert Lazarski <[email protected]>
AuthorDate: Tue Apr 7 09:56:45 2026 -1000

    Apply Gemini review findings — C3 MCP Resources cleanup
    
    Remove two redundant null checks flagged as LOW by Gemini review:
    - axisConfig.getServices() returns a non-null ConcurrentHashMap (initialized
      at construction) so the `if (services != null)` guard was unnecessary
    - service.getOperations() returns a non-null Iterator so the `opIter != 
null`
      check in the while-loop condition was unnecessary
    
    Also fixes indentation inside the for loop (was over-indented after the
    if-block removal).
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../apache/axis2/openapi/OpenApiSpecGenerator.java | 98 +++++++++++-----------
 1 file changed, 48 insertions(+), 50 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 c3220ae87e..8c71170c35 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
@@ -945,60 +945,58 @@ public class OpenApiSpecGenerator {
             com.fasterxml.jackson.databind.node.ArrayNode resources = 
root.putArray("resources");
 
             java.util.Map<String, AxisService> services = 
axisConfig.getServices();
-            if (services != null) {
-                for (AxisService service : services.values()) {
-                    String svcName = service.getName();
-                    if (isSystemService(svcName)) continue;
-
-                    // URI: logical identifier for the resource in the MCP 
protocol.
-                    // Uses the "axis2://" scheme so clients can distinguish 
these
-                    // resources from generic HTTP URLs.
-                    String uri = "axis2://services/" + svcName;
-
-                    // Human-readable description: service-level 
mcpDescription param
-                    // or auto-generated fallback.
-                    String description = getMcpStringParam(null, service, 
"mcpDescription",
-                            "Axis2 service: " + svcName);
-
-                    com.fasterxml.jackson.databind.node.ObjectNode resource =
-                            resources.addObject();
-                    resource.put("uri",         uri);
-                    resource.put("name",         svcName);
-                    resource.put("description",  description);
-                    resource.put("mimeType",     "application/json");
-
-                    // metadata sub-object: service-specific details for MCP 
clients
-                    // that want to introspect available operations before 
calling.
-                    com.fasterxml.jackson.databind.node.ObjectNode metadata =
-                            resource.putObject("metadata");
-                    metadata.put("wsdlUrl", "GET /services/" + svcName + 
"?wsdl");
-
-                    // List all non-system operation names.
-                    com.fasterxml.jackson.databind.node.ArrayNode ops = 
metadata.putArray("operations");
-                    java.util.Iterator<AxisOperation> opIter = 
service.getOperations();
-                    while (opIter != null && opIter.hasNext()) {
-                        AxisOperation op = opIter.next();
-                        if (op != null && op.getName() != null) {
-                            String opName = op.getName().getLocalPart();
-                            if (opName != null && !opName.startsWith("__")) {
-                                ops.add(opName);
-                            }
+            for (AxisService service : services.values()) {
+                String svcName = service.getName();
+                if (isSystemService(svcName)) continue;
+
+                // URI: logical identifier for the resource in the MCP 
protocol.
+                // Uses the "axis2://" scheme so clients can distinguish these
+                // resources from generic HTTP URLs.
+                String uri = "axis2://services/" + svcName;
+
+                // Human-readable description: service-level mcpDescription 
param
+                // or auto-generated fallback.
+                String description = getMcpStringParam(null, service, 
"mcpDescription",
+                        "Axis2 service: " + svcName);
+
+                com.fasterxml.jackson.databind.node.ObjectNode resource =
+                        resources.addObject();
+                resource.put("uri",         uri);
+                resource.put("name",         svcName);
+                resource.put("description",  description);
+                resource.put("mimeType",     "application/json");
+
+                // metadata sub-object: service-specific details for MCP 
clients
+                // that want to introspect available operations before calling.
+                com.fasterxml.jackson.databind.node.ObjectNode metadata =
+                        resource.putObject("metadata");
+                metadata.put("wsdlUrl", "GET /services/" + svcName + "?wsdl");
+
+                // List all non-system operation names.
+                com.fasterxml.jackson.databind.node.ArrayNode ops = 
metadata.putArray("operations");
+                java.util.Iterator<AxisOperation> opIter = 
service.getOperations();
+                while (opIter.hasNext()) {
+                    AxisOperation op = opIter.next();
+                    if (op != null && op.getName() != null) {
+                        String opName = op.getName().getLocalPart();
+                        if (opName != null && !opName.startsWith("__")) {
+                            ops.add(opName);
                         }
                     }
+                }
 
-                    // Auth requirement mirrors the tool catalog heuristic.
-                    String svcLower = 
svcName.toLowerCase(java.util.Locale.ROOT);
-                    boolean requiresAuth;
-                    String mcpRequiresAuthParam = getMcpStringParam(null, 
service,
-                            "mcpRequiresAuth", null);
-                    if (mcpRequiresAuthParam != null) {
-                        requiresAuth = 
!"false".equalsIgnoreCase(mcpRequiresAuthParam);
-                    } else {
-                        requiresAuth = !svcLower.equals("loginservice")
-                                    && !svcLower.equals("adminconsole");
-                    }
-                    metadata.put("requiresAuth", requiresAuth);
+                // Auth requirement mirrors the tool catalog heuristic.
+                String svcLower = svcName.toLowerCase(java.util.Locale.ROOT);
+                boolean requiresAuth;
+                String mcpRequiresAuthParam = getMcpStringParam(null, service,
+                        "mcpRequiresAuth", null);
+                if (mcpRequiresAuthParam != null) {
+                    requiresAuth = 
!"false".equalsIgnoreCase(mcpRequiresAuthParam);
+                } else {
+                    requiresAuth = !svcLower.equals("loginservice")
+                                && !svcLower.equals("adminconsole");
                 }
+                metadata.put("requiresAuth", requiresAuth);
             }
 
             log.debug("Generated MCP resources JSON ({} services)", 
resources.size());

Reply via email to