Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39841

null parallelStartNode in StandardChunkVisitor.parallelBranchStart()

      With nested parallel branch, parallelStartNode is passed as null. Its supposed to be non-null value, this behavior has consequence of causing NPE.

      public void parallelBranchStart(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchStartNode, @Nonnull ForkScanner scanner) {}
      
      node {
         stage ('test') { 
           echo ('Testing'); 
           parallel nestedBranch: {
             echo 'nested Branch'
             stage('nestedBranchStage') {
               echo 'running nestedBranchStage'
               parallel secondLevelNestedBranch1: {
                 echo 'secondLevelNestedBranch1'
               }
             }
           },
          failFast: false
         } 
      }
      

          [JENKINS-39841] null parallelStartNode in StandardChunkVisitor.parallelBranchStart()

          Vivek Pandey created issue -
          James Dumay made changes -
          Labels New: blueocean
          James Dumay made changes -
          Description Original: With nested parallel branch, parallelStartNode is passed as null. Its supposed to be non-null value, this behavior has consequence of causing NPE.

          {code}
          public void parallelBranchStart(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchStartNode, @Nonnull ForkScanner scanner) {}

          {code}
          node {
             stage ('test') {
               echo ('Testing');
               parallel nestedBranch: {
                 echo 'nested Branch'
                 stage('nestedBranchStage') {
                   echo 'running nestedBranchStage'
                   parallel secondLevelNestedBranch1: {
                     echo 'secondLevelNestedBranch1'
                   }
                 }
               },
              failFast: false
             }
          }
          {code}

          {code}
          New: With nested parallel branch, parallelStartNode is passed as null. Its supposed to be non-null value, this behavior has consequence of causing NPE.

          {code}
          public void parallelBranchStart(@Nonnull FlowNode parallelStartNode, @Nonnull FlowNode branchStartNode, @Nonnull ForkScanner scanner) {}
          {code}

          {code}
          node {
             stage ('test') {
               echo ('Testing');
               parallel nestedBranch: {
                 echo 'nested Branch'
                 stage('nestedBranchStage') {
                   echo 'running nestedBranchStage'
                   parallel secondLevelNestedBranch1: {
                     echo 'secondLevelNestedBranch1'
                   }
                 }
               },
              failFast: false
             }
          }
          {code}
          Sam Van Oort made changes -
          Assignee New: Sam Van Oort [ svanoort ]

          Sam Van Oort added a comment -

          Probably also needs the parallelStartPredicate to be set automatically if not done currently:

          public static Predicate<FlowNode> PARALLEL_START_PREDICATE = new Predicate<FlowNode>() {
                  @Override
                  public boolean apply(FlowNode input)

          {             return input != null && input instanceof StepStartNode && (((StepStartNode) input).getDescriptor().getClass() == ParallelStep.DescriptorImpl.class);         }

              };

          ForkScanner.setParallelStartPredicate(PARALLEL_START_PREDICATE);

          Sam Van Oort added a comment - Probably also needs the parallelStartPredicate to be set automatically if not done currently: public static Predicate<FlowNode> PARALLEL_START_PREDICATE = new Predicate<FlowNode>() {         @Override         public boolean apply(FlowNode input) {             return input != null && input instanceof StepStartNode && (((StepStartNode) input).getDescriptor().getClass() == ParallelStep.DescriptorImpl.class);         }     }; ForkScanner.setParallelStartPredicate(PARALLEL_START_PREDICATE);

          Vivek Pandey added a comment -

          svanoort I am not setting this predicate, wasn't aware of it. Looking at it, this seems one of default predicate in ForkScanner? Otherwise everyone doing this kind of thing needs to remember to set it up.

          Vivek Pandey added a comment - svanoort I am not setting this predicate, wasn't aware of it. Looking at it, this seems one of default predicate in ForkScanner? Otherwise everyone doing this kind of thing needs to remember to set it up.

          Sam Van Oort added a comment -

          vivek Due to a new API added to support other work for Step descriptions in flownodes, I've got the ability to set a working default predicate in this case now (requires workflow-cps v 2.26 to work completely though).

          Sam Van Oort added a comment - vivek Due to a new API added to support other work for Step descriptions in flownodes, I've got the ability to set a working default predicate in this case now (requires workflow-cps v 2.26 to work completely though).

          Vivek Pandey added a comment -

          Thanks svanoort

          Vivek Pandey added a comment - Thanks svanoort
          Sam Van Oort made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Sam Van Oort made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]

            svanoort Sam Van Oort
            vivek Vivek Pandey
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: