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

Swagger Core is not compatible with Jackson 2.18.x #4755

Closed
jamesnetherton opened this issue Oct 4, 2024 · 3 comments
Closed

Swagger Core is not compatible with Jackson 2.18.x #4755

jamesnetherton opened this issue Oct 4, 2024 · 3 comments
Labels

Comments

@jamesnetherton
Copy link

jamesnetherton commented Oct 4, 2024

ModelResolver.findJsonVauleType references Jackson BeanDescription.findJsonVauleMethod which was deprecated since Jackson 2.9. It got removed in Jackson 2.18.0, hence there's the potential for runtime errors if Jackson 2.18.x is on the classpath. Or build time errors if GraalVM is used to create a native application.

@micryc
Copy link
Contributor

micryc commented Oct 9, 2024

Hi @jamesnetherton thank you for reporting, possible problem should be solved by: #4756, Closing ticket for now, If you will experience any problem, feel free to reopen

@micryc micryc closed this as completed Oct 9, 2024
@metaxmx
Copy link

metaxmx commented Nov 21, 2024

Hi,
unfortunately the change in #4756 introduces new problems when using Jackson 2.18 (in my case: Jackson 2.18.1).
Now my log gets flooded with messages like:

2024-11-21 15:26:41,430	ERROR	io.swagger.v3.core.jackson.ModelResolver	Neither 'findJsonValueMethod' nor 'findJsonValueAccessor' found in jackson BeanDescription. Please verify your Jackson version.
2024-11-21 15:26:41,434	ERROR	io.swagger.v3.core.jackson.ModelResolver	Neither 'findJsonValueMethod' nor 'findJsonValueAccessor' found in jackson BeanDescription. Please verify your Jackson version.
...

After a bit of debugging, I found the reason:
In this Jackson version the method BeanDescription.findJsonValueAccessor() does exist, but BeanDescription.findJsonValueMethod() has been removed.
However, due to the code structure, the first call to invokeMethod(beanDesc, "findJsonValueAccessor") does not throw an exception, but returns null in my case. Therefore the function findJsonValueType does not return in the first try-Block, and still tries to execute the old/deprecated/removed method invokeMethod(beanDesc, "findJsonValueMethod"), which does print out the error.

I think this problem would be fixed, if the first executed method would just return a value anyways, if no exception during the method execution occurred.

E.g.

try {
    AnnotatedMember jsonValueMember = invokeMethod(beanDesc, "findJsonValueAccessor");
    if (jsonValueMember != null) {
        return jsonValueMember.getType();
    }
    return null;
} catch (Exception e) {
    LOGGER.warn("jackson BeanDescription.findJsonValueAccessor not found, this could lead to inaccurate result, please update jackson to 2.9+");
}

edit: I've encountered this problem with Swagger-Core 2.2.26, but also looked in the current master branch, and saw that the relevant code fragment is the same, as the one I've debugged with

@frantuma
Copy link
Member

fixed in #4806 4806

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

No branches or pull requests

5 participants