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 58e171ee40da02adae303ab171189ceb5b82f4dc Author: Robert Lazarski <robertlazar...@gmail.com> AuthorDate: Wed May 12 12:09:21 2021 -0400 AXIS2-5999 Return HTTP 404 instead 500 on 'The service cannot be found' --- modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java | 7 +++++-- .../http/src/org/apache/axis2/transport/http/AxisServlet.java | 3 +++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java b/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java index f096883..148470c 100644 --- a/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java +++ b/modules/kernel/src/org/apache/axis2/engine/DispatchPhase.java @@ -45,6 +45,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import javax.xml.namespace.QName; +import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -67,7 +68,7 @@ public class DispatchPhase extends Phase { Boolean disableAck = (Boolean) msgContext.getProperty(Constants.Configuration.DISABLE_RESPONSE_ACK); if(disableAck == null) { disableAck = (Boolean) (msgContext.getAxisService() != null ? msgContext.getAxisService().getParameterValue(Constants.Configuration.DISABLE_RESPONSE_ACK) : null); - } + } return disableAck; } @@ -79,6 +80,8 @@ public class DispatchPhase extends Phase { AxisFault fault = new AxisFault(Messages.getMessage("servicenotfoundforepr", ((toEPR != null) ? toEPR.getAddress() : ""))); fault.setFaultCode(org.apache.axis2.namespace.Constants.FAULT_CLIENT); + Integer not_found = HttpServletResponse.SC_NOT_FOUND; + msgContext.setProperty(Constants.HTTP_RESPONSE_STATE, not_found.toString()); throw fault; } @@ -403,4 +406,4 @@ public class DispatchPhase extends Phase { || mepString.equals(WSDL2Constants.MEP_URI_IN_ONLY)); } -} \ No newline at end of file +} diff --git a/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java b/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java index 1d8eed9..603ec95 100644 --- a/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java +++ b/modules/transport/http/src/org/apache/axis2/transport/http/AxisServlet.java @@ -392,9 +392,12 @@ public class AxisServlet extends HttpServlet { String status = (String) msgContext.getProperty(Constants.HTTP_RESPONSE_STATE); if (status == null) { + log.error("processAxisFault() found null HTTP status from the MessageContext instance, setting HttpServletResponse status to: " + Constants.HTTP_RESPONSE_STATE); res.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } else { + log.error("processAxisFault() found HTTP status from the MessageContext instance, setting HttpServletResponse status to: " + status); res.setStatus(Integer.parseInt(status)); + return; } AxisBindingOperation axisBindingOperation =