forked from digma-ai/forkof-spring-petclinic
-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
An IllegalStateException is occurring in the GET /owners/{ownerId}/pets endpoint due to improper handling of multiple pets per owner in the stream collection operation.
Problem:
The current implementation fails when attempting to merge pet lists for owners with multiple pets (specifically observed with owner ID 6 having pets 7 and 8).
Root Cause:
The stream collection operation using toMap does not properly handle the case where an owner has multiple pets, leading to duplicate key exceptions.
Solution:
A PR has been created (#357) that implements the following fixes:
- Replaces toMap collector with groupingBy to properly handle multiple pets per owner
- Uses ArrayList for mutable list structures
- Adds proper null handling
- Fixes the stream collection logic for multiple pets
Testing:
The fix has been tested with:
- Owner ID 6 (having pets 7 and 8)
- Owners with single pets
- Owners with no pets
Please review and merge PR #357 to resolve this issue.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request