Announcement Announcement Module
Collapse
No announcement yet.
Incorrect implementation of equals()/hashCode() in ExitStatus? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Incorrect implementation of equals()/hashCode() in ExitStatus?

    Hello,

    I was wondering whether there is a reason for the equals()/hashCode() methods in the ExitStatus class to be implemented the way they are now (release 2.1.6):
    Code:
            public boolean equals(Object obj) {
    		if (obj == null) {
    			return false;
    		}
    		return toString().equals(obj.toString());
    	}
    Code:
       public int hashCode() {
    		return toString().hashCode();
    	}
    with the toString() being:
    Code:
     public String toString() {
    		return String.format("exitCode=%s;exitDescription=%s", exitCode, exitDescription);
    	}
    In my case, this implementation is causing incorrect behaviour. e.g. the following statement in the if block returns false even when the exitStatus of the stepExecution is FAILED:
    Code:
      {
        ........................
         if (ExitStatus.FAILED.equals(stepExecution.getExitStatus())){
            ..............
         }
        ........................
      }
    and the reason for that is because the exitStatus of the stepExecution contains a description of the error (e.g. the exception trace) while the class one obviously doesn't.

    Why can't the exitCode *only* be used to uniquely identify an ExitStatus?

    Any thoughts?

    Cheers,
    Savvas
Working...
X