zoukankan      html  css  js  c++  java
  • [Java] 在SoapUI里使用equals()方法时报java.lang.StackOverflowError

    开始这样使用的时候一直报java.lang.StackOverflowError

            public boolean equals(Object o) {
                if(this == o)
                    return true;
                if(o == null || getClass() != o.getClass())
                    return false;
                HoldingInfo that = (HoldingInfo)o;
                return Objects.equals(performanceId, that.performanceId) && Objects.equals(name, that.name) && Objects.equals(weight, that.weight);
            }
    
            public int hashCode(){
                return Objects.hash(performanceId,name,weight);
            }

    修改后就好了,上面这种写法当执行equal检查时,它将一次又一次的被它自己调用,直到堆栈溢出

            public boolean equals(Object o) {
                if(this.is(o))
                    return true;
                if(o == null || getClass() != o.getClass())
                    return false;
                HoldingInfo that = (HoldingInfo)o;
                return Objects.equals(performanceId, that.performanceId) && Objects.equals(name, that.name) && Objects.equals(weight, that.weight);
            }
    
            public int hashCode(){
                return Objects.hash(performanceId,name,weight);
            }
  • 相关阅读:
    SQL中的union
    SQL的类型转换
    Keytool生成证书
    Openssl生成证书
    Python示例-Json Parse
    Python示例-TCP Port Scan
    Python套接字
    TCP端口扫描
    Linux环境变量
    Python示例-Logging
  • 原文地址:https://www.cnblogs.com/wynlfd/p/6565993.html
Copyright © 2011-2022 走看看