Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor getFaultStringOrReason to Return Optional and Update JavaDoc #1428

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
import org.springframework.ws.soap.SoapFault;
import org.springframework.ws.soap.SoapMessage;

import java.util.Optional;

/**
* Thrown by {@code SoapFaultMessageResolver} when the response message has a fault.
*
Expand Down Expand Up @@ -56,13 +58,17 @@ public QName getFaultCode() {
}

/**
* Returns the fault string or reason. For SOAP 1.1, this returns the fault string. For SOAP 1.2, this returns the
* fault reason for the default locale.
* Returns the fault string or reason from the SOAP fault.
* For SOAP 1.1, this method returns the fault string. For SOAP 1.2, it returns the fault reason for the default locale.
* <p>
* Note that this method returns the same value as {@link #getMessage()}.
* <p>
* Note that this message returns the same as {@link #getMessage()}.
* The returned value is wrapped in an {@link Optional}. If the SOAP fault is not present, an empty {@link Optional} is returned.
*
* @return an {@link Optional} containing the fault string or reason if present, or an empty {@link Optional} if the SOAP fault is not present.
*/
public String getFaultStringOrReason() {
return soapFault != null ? soapFault.getFaultStringOrReason() : null;
public Optional<String> getFaultStringOrReason() {
return Optional.ofNullable(this.soapFault)
.map(SoapFault::getFaultStringOrReason);
}

}