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

LazyList does not allow range access

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.8.9, 2.0.8, 2.1.3
    • 2.2.0-beta-1
    • groovy-jdk
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: