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

LazyList does not allow range access

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.8.9, 2.0.8, 2.1.3
    • Fix Version/s: 2.2.0-beta-1
    • Component/s: groovy-jdk
    • Labels:
      None

      Description

      This pieces of code raises on IndexOutOfBoundsException:

      def a = [1].withDefault {42}
      assert a[2..-1] == [42]
      
      java.lang.IndexOutOfBoundsException: toIndex = 3
      
      	at java.util.SubList.<init>(Unknown Source)
      
      	at java.util.RandomAccessSubList.<init>(Unknown Source)
      
      	at java.util.AbstractList.subList(Unknown Source)
      
      	at groovy.lang.ListWithDefault.subList(ListWithDefault.java:237)
      
      	at org.codehaus.groovy.runtime.DefaultGroovyMethods.getAt(DefaultGroovyMethods.java:4864)
      
      

      ListWithDefault#subList(int, int) should handle this case instead of delegating to List#subList(int, int)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                asteingress Andre Steingress
                Reporter:
                asteingress Andre Steingress
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: