From a7a2726194579ec90b26833864a163ce53382862 Mon Sep 17 00:00:00 2001 From: hduelme Date: Thu, 26 Jan 2023 21:34:56 +0100 Subject: [PATCH] Remove null checks from instanceof checks. As of Java 11, the Jave language officially declares that instanceof checks include a null check, hence no need to do them in our code. Resolves #1326. --- .../org/springframework/ws/server/endpoint/MethodEndpoint.java | 2 +- .../adapter/XPathParamAnnotationMethodEndpointAdapter.java | 2 +- .../ws/soap/addressing/core/EndpointReference.java | 2 +- .../ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java | 2 +- .../java/org/springframework/xml/namespace/QNameEditor.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java index d7186572..f67f5ccb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/MethodEndpoint.java @@ -156,7 +156,7 @@ public final class MethodEndpoint { if (this == o) { return true; } - if (o != null && o instanceof MethodEndpoint) { + if (o instanceof MethodEndpoint) { MethodEndpoint other = (MethodEndpoint) o; return this.bean.equals(other.bean) && this.method.equals(other.method); } diff --git a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java index 3d51d90c..67c4df8e 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/server/endpoint/adapter/XPathParamAnnotationMethodEndpointAdapter.java @@ -127,7 +127,7 @@ public class XPathParamAnnotationMethodEndpointAdapter extends AbstractMethodEnd Element payloadElement = getRootElement(messageContext.getRequest().getPayloadSource()); Object[] args = getMethodArguments(payloadElement, methodEndpoint.getMethod()); Object result = methodEndpoint.invoke(args); - if (result != null && result instanceof Source) { + if (result instanceof Source) { Source responseSource = (Source) result; WebServiceMessage response = messageContext.getResponse(); transform(responseSource, response.getPayloadResult()); diff --git a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java index fdd3e785..e17625cb 100644 --- a/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java +++ b/spring-ws-core/src/main/java/org/springframework/ws/soap/addressing/core/EndpointReference.java @@ -90,7 +90,7 @@ public final class EndpointReference implements Serializable { if (this == o) { return true; } - if (o != null && o instanceof EndpointReference) { + if (o instanceof EndpointReference) { EndpointReference other = (EndpointReference) o; return address.equals(other.address); } diff --git a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java index 62336491..93ef8bab 100644 --- a/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java +++ b/spring-ws-security/src/main/java/org/springframework/ws/soap/security/wss4j2/Wss4jSecurityInterceptor.java @@ -852,7 +852,7 @@ public class Wss4jSecurityInterceptor extends AbstractWsSecurityInterceptor impl if (!CollectionUtils.isEmpty(results)) { WSSecurityEngineResult actionResult = results.get(0); Principal principal = (Principal) actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL); - if (principal != null && principal instanceof WSUsernameTokenPrincipalImpl) { + if (principal instanceof WSUsernameTokenPrincipalImpl) { WSUsernameTokenPrincipalImpl usernameTokenPrincipal = (WSUsernameTokenPrincipalImpl) principal; UsernameTokenPrincipalCallback callback = new UsernameTokenPrincipalCallback(usernameTokenPrincipal); try { diff --git a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java index 5b2e1484..a3053960 100644 --- a/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java +++ b/spring-xml/src/main/java/org/springframework/xml/namespace/QNameEditor.java @@ -62,7 +62,7 @@ public class QNameEditor extends PropertyEditorSupport { @Override public String getAsText() { Object value = getValue(); - if (value == null || !(value instanceof QName)) { + if (!(value instanceof QName)) { return ""; } else { QName qName = (QName) value;