Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-7902

collate() infinite loop with zeroed step

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.4.7
    • 2.5.0-alpha-1
    • groovy-jdk, groovy-runtime
    • None
    • Groovy Version: 2.4.7 JVM: 1.8.0_92 Vendor: Oracle Corporation OS: Mac OS X

    Description

      Fixing infinite loop in Iterable.collate method when step parameter is equals to zero.

      Example:

      [ 1, 2, 3 ].collate( 2, 0 )
      

      The result is a infinite loop because the step parameter is used directly in the for increment: pos += step

      In the fixing I assumed that the step parameter should be equals to size parameter, looks like in the collate(self, size, size, keepRemainder) overloaded method, with absence of step and I considered backward compatibility with negative steps.

      PR opened in Github: https://github.com/apache/groovy/pull/378

      Thks.
      Felipe Mamud

      Attachments

        Issue Links

          Activity

            People

              paulk Paul King
              ftmamud Felipe Mamud
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: