An IllegalStateException is occurring in the GET /owners/pets endpoint when an owner has multiple pets. This is due to the use of Collectors.toMap() which doesn't handle duplicate keys properly.
Root Cause:
- The getOwnerPetsMap method uses Collectors.toMap() which throws IllegalStateException on duplicate keys
- Multiple pets belonging to the same owner cause duplicate owner_id keys
Fix:
- Modified the code to use Collectors.groupingBy instead of Collectors.toMap
- Added proper handling of multiple pets per owner
- Improved error handling and logging
Related PR: #90