Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log debug instead of warn when introspected entity cannot be mapped and falls back to mongo deserialize #3261

Open
wants to merge 2 commits into
base: 4.10.x
Choose a base branch
from

Conversation

radovanradic
Copy link
Contributor

The reported issue is not failing but just seeing logged warning. This PR keeps the same behavior added in #2950, adds test from the issue and changes log from warn to debug.

@@ -168,8 +168,10 @@ protected <R> R convertResult(CodecRegistry codecRegistry,
try {
return mapIntrospectedObject(result, resultType);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens here is we get this map
Screenshot 2024-12-09 at 1 19 57 PM
which cannot be deserialized to the record

record CustomerView(@BsonId @BsonRepresentation(OBJECT_ID) String id, String firstName, String lastName) {
}

because _id and id are mismatched in introspected mapper. Therefore we catch exception and fallback to this code

else if (isDtoProjection) {
            R dtoResult = MongoUtils.toValue(result.asDocument(), resultType, codecRegistry);
            if (resultType.isInstance(dtoResult)) {
                return dtoResult;
            }
            return conversionService.convertRequired(dtoResult, resultType);
        }

Copy link

sonarcloud bot commented Dec 9, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant