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 e1ec5178de3bf7d6858408b2620cba754d138a32
Author: Robert Lazarski <[email protected]>
AuthorDate: Mon May 4 14:39:38 2026 -1000

    AXIS2-6104 Add legacy status/errorMessage fields for backward compatibility
    
    Axis2JsonErrorResponse now includes "status":"FAILED" and "errorMessage"
    alongside the new structured fields (error, errorRef, timestamp).  Existing
    clients that parse {"status":"FAILED","errorMessage":"..."} continue to
    work unchanged.  New clients use the structured error/errorRef/timestamp
    fields for correlation and retry logic.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
---
 .../json/gson/rpc/Axis2JsonErrorResponse.java      | 24 +++++++++++++++++++++-
 .../webservices/FinancialBenchmarkServiceTest.java |  7 +++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git 
a/modules/json/src/org/apache/axis2/json/gson/rpc/Axis2JsonErrorResponse.java 
b/modules/json/src/org/apache/axis2/json/gson/rpc/Axis2JsonErrorResponse.java
index ff242a7eb5..a6f20ac15e 100644
--- 
a/modules/json/src/org/apache/axis2/json/gson/rpc/Axis2JsonErrorResponse.java
+++ 
b/modules/json/src/org/apache/axis2/json/gson/rpc/Axis2JsonErrorResponse.java
@@ -69,10 +69,24 @@ import java.util.UUID;
  */
 public class Axis2JsonErrorResponse {
 
+    // ── Legacy fields (backward compatibility) ─────────────────────────────
+    // Existing clients check these two fields to detect errors.  Removing them
+    // would break every caller that parses 
{"status":"FAILED","errorMessage":"..."}.
+    // Kept alongside the new structured fields so old and new clients both 
work
+    // from the same response body.
+
+    /** Always "FAILED" — matches the legacy 
PortfolioVarianceResponse.failed() contract. */
+    private final String status = "FAILED";
+
+    /** Human-readable error message (legacy field name).  Same value as 
{@link #message}. */
+    private String errorMessage;
+
+    // ── New structured fields 
────────────────────────────────────────────────
+
     /** Error code — e.g. VALIDATION_ERROR, RATE_LIMITED, SERVICE_UNAVAILABLE, 
INTERNAL_ERROR */
     private String error;
 
-    /** Human-readable error message */
+    /** Human-readable error message (new field name, same value as 
errorMessage) */
     private String message;
 
     /** Opaque correlation ID for server-side log lookup */
@@ -91,6 +105,7 @@ public class Axis2JsonErrorResponse {
                                    String timestamp, Integer retryAfter) {
         this.error = error;
         this.message = message;
+        this.errorMessage = message;  // legacy field — same value
         this.errorRef = errorRef;
         this.timestamp = timestamp;
         this.retryAfter = retryAfter;
@@ -155,6 +170,13 @@ public class Axis2JsonErrorResponse {
 
     // ── Getters / setters 
────────────────────────────────────────────────────
 
+    /** Always "FAILED" — read-only for backward compatibility. */
+    public String getStatus() { return status; }
+
+    /** Legacy error message field. Same value as {@link #getMessage()}. */
+    public String getErrorMessage() { return errorMessage; }
+    public void setErrorMessage(String errorMessage) { this.errorMessage = 
errorMessage; }
+
     public String getError() { return error; }
     public void setError(String error) { this.error = error; }
 
diff --git 
a/modules/samples/userguide/src/userguide/springbootdemo-tomcat11/src/test/java/userguide/springboot/webservices/FinancialBenchmarkServiceTest.java
 
b/modules/samples/userguide/src/userguide/springbootdemo-tomcat11/src/test/java/userguide/springboot/webservices/FinancialBenchmarkServiceTest.java
index ddcac640d2..78db0dc2db 100644
--- 
a/modules/samples/userguide/src/userguide/springbootdemo-tomcat11/src/test/java/userguide/springboot/webservices/FinancialBenchmarkServiceTest.java
+++ 
b/modules/samples/userguide/src/userguide/springbootdemo-tomcat11/src/test/java/userguide/springboot/webservices/FinancialBenchmarkServiceTest.java
@@ -228,10 +228,17 @@ class FinancialBenchmarkServiceTest {
         JsonRpcFaultException ex = assertThrows(JsonRpcFaultException.class,
             () -> service.portfolioVariance(null));
         assertEquals(422, ex.getHttpStatusCode());
+        // New structured fields
         assertEquals("VALIDATION_ERROR", ex.getErrorResponse().getError());
         assertNotNull(ex.getErrorResponse().getErrorRef(), "errorRef UUID must 
be present");
         assertNotNull(ex.getErrorResponse().getTimestamp(), "timestamp must be 
present");
         assertNull(ex.getErrorResponse().getRetryAfter(), "retryAfter should 
be null for 422");
+        // Legacy fields — backward compatible with clients that check
+        // {"status":"FAILED","errorMessage":"..."}
+        assertEquals("FAILED", ex.getErrorResponse().getStatus());
+        assertNotNull(ex.getErrorResponse().getErrorMessage());
+        assertEquals(ex.getErrorResponse().getMessage(), 
ex.getErrorResponse().getErrorMessage(),
+            "errorMessage must equal message for backward compatibility");
     }
 
     // ═══════════════════════════════════════════════════════════════════════

Reply via email to