Skip to content

RecursiveCollectionLineAggregator.aggregate() fails on empty collection input #5023

@florian-serraille

Description

@florian-serraille

Bug description

When calling RecursiveCollectionLineAggregator.aggregate() with an empty collection, the method throws a StringIndexOutOfBoundsException due to an unguarded StringBuilder.delete(...) call.

Expected behavior

It should return an empty string ("") without throwing an exception.

Minimal Complete Reproducible example

In RecursiveCollectionLineAggregatorTests.class:

@Test
void testSetDelegateAndPassEmptyCollection() {
    RecursiveCollectionLineAggregator<String> aggregator = new RecursiveCollectionLineAggregator<>();
    aggregator.setDelegate(item -> "bar");
    assertEquals("", aggregator.aggregate(Collections.emptyList()));
}

Result: java.lang.StringIndexOutOfBoundsException

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions