Ticket #20587: 20587.patch

File 20587.patch, 881 bytes (added by taylor.smock, 4 years ago)

Use this.stream().toArray() instead of this.toList().toArray() for the toArray() function, and document why

  • src/org/openstreetmap/josm/data/osm/QuadBuckets.java

     
    454454
    455455    @Override
    456456    public Object[] toArray() {
    457         return this.toList().toArray();
     457        // Don't call toList() -- in some cases, this can produce an infinite loop
     458        // For example, ArrayList may call toArray to get the initial array. However, since we are
     459        // creating a new ArrayList in toList with `this`, this creates an infinite recursion loop.
     460        // So a `toArray` call becomes `toArray -> toList -> toArray -> toList -> toArray -> ...`
     461        // For more information, see #20587.
     462        return this.stream().toArray();
    458463    }
    459464
    460465    @Override