Skip to content

Commit db273fc

Browse files
AXIS2-6104 Null-check getOpMethod, sanitize test data
- All four message receivers (gson + moshi, InOut + InOnly) now check for null return from getOpMethod() and throw a clear AxisFault with the operation name and service class, instead of NPE - Replace proprietary department names in pagination test with generic "Department A" through "Department O" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 72b2ccb commit db273fc

5 files changed

Lines changed: 20 additions & 4 deletions

File tree

modules/json/src/org/apache/axis2/json/gson/rpc/JsonInOnlyRPCMessageReceiver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public void invokeService(JsonReader jsonReader, Object serviceObj, String opera
7373
Class implClass = serviceObj.getClass();
7474
Method[] allMethods = implClass.getDeclaredMethods();
7575
Method method = JsonUtils.getOpMethod(operation_name, allMethods);
76+
if (method == null) {
77+
throw new AxisFault("Operation '" + operation_name
78+
+ "' not found on service class " + implClass.getName());
79+
}
7680
Class[] paramClasses = method.getParameterTypes();
7781
try {
7882
int paramCount = paramClasses.length;

modules/json/src/org/apache/axis2/json/gson/rpc/JsonRpcMessageReceiver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public void invokeService(JsonReader jsonReader, Object serviceObj, String opera
7575
Class implClass = serviceObj.getClass();
7676
Method[] allMethods = implClass.getDeclaredMethods();
7777
Method method = JsonUtils.getOpMethod(operation_name, allMethods);
78+
if (method == null) {
79+
throw new AxisFault("Operation '" + operation_name
80+
+ "' not found on service class " + implClass.getName());
81+
}
7882
Class[] paramClasses = method.getParameterTypes();
7983
try {
8084
int paramCount = paramClasses.length;

modules/json/src/org/apache/axis2/json/moshi/rpc/JsonInOnlyRPCMessageReceiver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ public void invokeService(JsonReader jsonReader, Object serviceObj, String opera
7373
Class implClass = serviceObj.getClass();
7474
Method[] allMethods = implClass.getDeclaredMethods();
7575
Method method = JsonUtils.getOpMethod(operation_name, allMethods);
76+
if (method == null) {
77+
throw new AxisFault("Operation '" + operation_name
78+
+ "' not found on service class " + implClass.getName());
79+
}
7680
Class[] paramClasses = method.getParameterTypes();
7781
try {
7882
int paramCount = paramClasses.length;

modules/json/src/org/apache/axis2/json/moshi/rpc/JsonRpcMessageReceiver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public void invokeService(JsonReader jsonReader, Object serviceObj, String opera
7575
Class implClass = serviceObj.getClass();
7676
Method[] allMethods = implClass.getDeclaredMethods();
7777
Method method = JsonUtils.getOpMethod(operation_name, allMethods);
78+
if (method == null) {
79+
throw new AxisFault("Operation '" + operation_name
80+
+ "' not found on service class " + implClass.getName());
81+
}
7882
Class[] paramClasses = method.getParameterTypes();
7983
try {
8084
int paramCount = paramClasses.length;

modules/json/test/org/apache/axis2/json/rpc/PaginatedResponseTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,10 @@ public void testEnterprise_unpaginated_smallLookupTable() {
337337
// Scenario: a lookup/reference table (e.g. list of 15 departments).
338338
// No pagination needed — return the full set with hasMore=false.
339339
List<String> departments = Arrays.asList(
340-
"Equity Long/Short", "Fixed Income", "Macro", "Quant",
341-
"Event Driven", "Multi-Strategy", "Credit", "Real Assets",
342-
"Private Equity", "Venture", "Commodities", "FX",
343-
"Emerging Markets", "Infrastructure", "Insurance-Linked");
340+
"Department A", "Department B", "Department C", "Department D",
341+
"Department E", "Department F", "Department G", "Department H",
342+
"Department I", "Department J", "Department K", "Department L",
343+
"Department M", "Department N", "Department O");
344344

345345
PaginatedResponse<String> resp = PaginatedResponse.unpaginated(departments);
346346

0 commit comments

Comments
 (0)