[ 
https://issues.apache.org/jira/browse/TWILL-136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14590913#comment-14590913
 ] 

ASF GitHub Bot commented on TWILL-136:
--------------------------------------

Github user anew commented on a diff in the pull request:

    https://github.com/apache/incubator-twill/pull/43#discussion_r32689733
  
    --- Diff: 
twill-core/src/main/java/org/apache/twill/internal/JvmOptions.java ---
    @@ -83,5 +84,36 @@ public boolean doSuspend() {
         public boolean doDebug(String runnable) {
           return doDebug && (runnables == null || 
runnables.contains(runnable));
         }
    +
    +    @Override
    +    public boolean equals(Object object) {
    +      if (this == object) {
    +        return true;
    +      }
    +      if (!(object instanceof DebugOptions)) {
    +        return false;
    +      }
    +
    +      DebugOptions that = (DebugOptions) object;
    +      return (this.doDebug == that.doDebug()) && (this.doSuspend == 
this.doSuspend()) &&
    +        (this.runnables != null ? ((that.getRunnables() != null) && 
this.getRunnables().equals(that.getRunnables())) :
    --- End diff --
    
    I prefer using Objects.equal(), it is much nicer to read.


> Override equals and hashCode for JvmOptions.DebugOptions to test equality
> -------------------------------------------------------------------------
>
>                 Key: TWILL-136
>                 URL: https://issues.apache.org/jira/browse/TWILL-136
>             Project: Apache Twill
>          Issue Type: Bug
>          Components: core
>            Reporter: Henry Saputra
>            Assignee: Henry Saputra
>
> The current code for JvmOptions.DebugOptions does not have equals and 
> hashCode overriden for equality test.
> This would cause fail comparison for DebugOptions.NO_DEBUG when being used in 
> YarnTwillPreparer:
> {code}
> final class YarnTwillPreparer implements TwillPreparer {
> ...
>   @Override
>   public TwillPreparer enableDebugging(boolean doSuspend, String... 
> runnables) {
>     this.debugOptions = new JvmOptions.DebugOptions(true, doSuspend, 
> ImmutableSet.copyOf(runnables));
>     return this;
>   }
> ....
>   private void saveJvmOptions(Map<String, LocalFile> localFiles) throws 
> IOException {
>     if ((extraOptions == null || extraOptions.isEmpty()) &&
>       JvmOptions.DebugOptions.NO_DEBUG.equals(this.debugOptions)) {
>       // If no vm options, no need to localize the file.
>       return;
>     }
>     ...
>   }
> ...
> }
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to