This is an automated email from the ASF dual-hosted git repository. buhhunyx pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/cxf-fediz.git
commit 90c309ef3748aca2bc2fbdff619e177fb26b63da Author: Alexey Markevich <[email protected]> AuthorDate: Tue Mar 24 11:17:20 2020 +0300 fediz-core: use Objects for equals in Protocol --- .../org/apache/cxf/fediz/core/config/Protocol.java | 25 +++++++--------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/Protocol.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/Protocol.java index e89aa86..3f1e498 100644 --- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/Protocol.java +++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/config/Protocol.java @@ -21,6 +21,7 @@ package org.apache.cxf.fediz.core.config; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.security.auth.callback.CallbackHandler; @@ -44,23 +45,21 @@ public abstract class Protocol { private Object reply; public Protocol(ProtocolType protocolType) { - super(); this.protocolType = protocolType; if (protocolType.getTokenValidators() != null && protocolType.getTokenValidators().getValidator() != null) { for (String validatorClassname : protocolType.getTokenValidators().getValidator()) { - Object obj = null; try { - obj = ClassLoaderUtils.loadClass(validatorClassname, this.getClass()).newInstance(); + Object obj = ClassLoaderUtils.loadClass(validatorClassname, this.getClass()).newInstance(); + if (obj instanceof TokenValidator) { + validators.add((TokenValidator)obj); + } else { + LOG.error("Invalid TokenValidator implementation class: '" + validatorClassname + "'"); + } } catch (Exception ex) { LOG.error("Failed to instantiate TokenValidator implementation class: '" + validatorClassname + "'\n" + ex.getClass().getCanonicalName() + ": " + ex.getMessage()); } - if (obj instanceof TokenValidator) { - validators.add((TokenValidator)obj); - } else if (obj != null) { - LOG.error("Invalid TokenValidator implementation class: '" + validatorClassname + "'"); - } } } } @@ -81,15 +80,7 @@ public abstract class Protocol { if (!(obj instanceof Protocol)) { return false; } - - Protocol that = (Protocol)obj; - if (protocolType != null && !protocolType.equals(that.getProtocolType())) { - return false; - } else if (protocolType == null && that.getProtocolType() != null) { - return false; - } - - return true; + return Objects.equals(protocolType, ((Protocol) obj).getProtocolType()); } public String toString() {
