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
Multiple versions of org.springframework:spring-web:jar, leading to inconsistent semantic behaviors #1143
Comments
Using the following test case to run on these two versions of methods separately starting from the entry method springHandlerInstantiator.namingStrategyInstance(deserializationConfig, null, implClass) in your project, then we can find that variable propertyNamingStrategy is assigned different values. Please check whether the changes of this variable value will affect your semantic behaviors. I can submit a PR to fix it, if you concern this issue. |
@HelloCoCooo Yes please, that would be great |
Hi, there are multiple versions of org.springframework:spring-web:jar in rest-assured-3.3.0. As shown in the following dependency tree, according to Maven's dependency management strategy, only org.springframework:spring-web:jar:4.2.6.RELEASE can be loaded, and org.springframework:spring-web:jar:4.3.19.RELEASE will be shadowed.
The following risky methods included in the shadowed version org.springframework:spring-web:jar:4.3.19.RELEASE are referenced by your project, but these methods are missing in the actual loaded version org.springframework:spring-web:jar:4.2.6.RELEASE. Surprisingly, it will not cause NoSuchMethodError at rumtime.
Risky method list:
<org.springframework.http.converter.json.SpringHandlerInstantiator.namingStrategyInstance(MapperConfig, Annotated, java.lang.Class)>
<org.springframework.http.converter.json.SpringHandlerInstantiator.virtualPropertyWriterInstance(MapperConfig, java.lang.Class)>
<org.springframework.http.converter.json.SpringHandlerInstantiator.converterInstance(MapperConfig, Annotated, java.lang.Class)>
<org.springframework.http.converter.json.SpringHandlerInstantiator.valueInstantiatorInstance(MapperConfig, Annotated, java.lang.Class)>
<org.springframework.http.converter.json.SpringHandlerInstantiator.resolverIdGeneratorInstance(MapperConfig, Annotated, java.lang.Class)>
<org.springframework.http.converter.json.SpringHandlerInstantiator.objectIdGeneratorInstance(MapperConfig, Annotated, java.lang.Class)>
For instance, method <org.springframework.http.converter.json.SpringHandlerInstantiator.namingStrategyInstance(MapperConfig, Annotated, java.lang.Class)> is invoked via the following expected path:
By further analyzing, I found that the caller belonging to rest-assured-3.3.0 would invoke the methods HandlerInstantiator.namingStrategyInstance(...), HandlerInstantiator.virtualPropertyWriterInstance(...), HandlerInstantiator.converterInstance(...), HandlerInstantiator.valueInstantiatorInstance(...), HandlerInstantiator.resolverIdGeneratorInstance(...), HandlerInstantiator.objectIdGeneratorInstance(...) defined in the superclass of SpringHandlerInstantiator (SpringHandlerInstantiator extends HandlerInstantiator) with the same signature of the expected callee, due to dynamic binding mechanism.
Although the actual invoked methods belonging to HandlerInstantiator has the same method names, same parameter types and return types as the expected methods defined in its subclass SpringHandlerInstantiator, but they has different control flows and different behaviors. Maybe it is buggy behavior.
Solution:
Use the newer version org.springframework:spring-web:jar:4.3.19.RELEASE to keep the version consistency.
Dependency tree---------
[INFO] io.rest-assured:spring-mock-mvc:jar:3.3.0
[INFO] +- io.rest-assured:rest-assured:jar:3.3.0:compile
[INFO] | +- org.codehaus.groovy:groovy:jar:2.4.15:compile
[INFO] | +- org.codehaus.groovy:groovy-xml:jar:2.4.15:compile
[INFO] | | - (org.codehaus.groovy:groovy:jar:2.4.15:compile - omitted for duplicate)
[INFO] | +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
[INFO] | | +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] | | +- commons-logging:commons-logging:jar:1.2:compile
[INFO] | | - commons-codec:commons-codec:jar:1.9:compile
[INFO] | +- org.apache.httpcomponents:httpmime:jar:4.5.1:compile
[INFO] | | - (org.apache.httpcomponents:httpclient:jar:4.5.1:compile - omitted for conflict with 4.5.3)
[INFO] | +- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- org.hamcrest:hamcrest-library:jar:1.3:compile
[INFO] | | - (org.hamcrest:hamcrest-core:jar:1.3:compile - omitted for duplicate)
[INFO] | +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile
[INFO] | +- io.rest-assured:json-path:jar:3.2.0:compile
[INFO] | | +- org.codehaus.groovy:groovy-json:jar:2.4.15:compile
[INFO] | | | - (org.codehaus.groovy:groovy:jar:2.4.15:compile - omitted for duplicate)
[INFO] | | +- (org.codehaus.groovy:groovy:jar:2.4.15:compile - omitted for duplicate)
[INFO] | | - io.rest-assured:rest-assured-common:jar:3.2.0:compile
[INFO] | | +- (org.codehaus.groovy:groovy:jar:2.4.15:compile - omitted for duplicate)
[INFO] | | - (org.apache.commons:commons-lang3:jar:3.4:compile - omitted for duplicate)
[INFO] | - io.rest-assured:xml-path:jar:3.2.0:compile
[INFO] | +- (org.codehaus.groovy:groovy-xml:jar:2.4.15:compile - omitted for duplicate)
[INFO] | +- (org.codehaus.groovy:groovy:jar:2.4.15:compile - omitted for duplicate)
[INFO] | +- (io.rest-assured:rest-assured-common:jar:3.2.0:compile - omitted for duplicate)
[INFO] | +- org.apache.commons:commons-lang3:jar:3.4:compile
[INFO] | +- (org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:compile - omitted for duplicate)
[INFO] | +- javax.xml.bind:jaxb-api:jar:2.2.12:compile
[INFO] | +- com.sun.xml.bind:jaxb-osgi:jar:2.2.10:compile
[INFO] | - org.apache.sling:org.apache.sling.javax.activation:jar:0.1.0:compile
[INFO] | - javax.activation:activation:jar:1.1.1:compile
[INFO] +- io.rest-assured:spring-commons:jar:3.2.0:compile
[INFO] | - (io.rest-assured:rest-assured:jar:3.2.0:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-test:jar:4.2.6.RELEASE:compile
[INFO] | - org.springframework:spring-core:jar:4.2.6.RELEASE:compile
[INFO] | - (commons-logging:commons-logging:jar:1.2:compile - omitted for duplicate)
[INFO] +- org.springframework:spring-webmvc:jar:4.2.6.RELEASE:compile
[INFO] | +- org.springframework:spring-beans:jar:4.2.6.RELEASE:compile
[INFO] | | - (org.springframework:spring-core:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-context:jar:4.2.6.RELEASE:compile
[INFO] | | +- (org.springframework:spring-aop:jar:4.2.6.RELEASE:compile - omitted for conflict with 4.3.19.RELEASE)
[INFO] | | +- (org.springframework:spring-beans:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-core:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | | - (org.springframework:spring-expression:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-core:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework:spring-expression:jar:4.2.6.RELEASE:compile
[INFO] | | - (org.springframework:spring-core:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | - org.springframework:spring-web:jar:4.2.6.RELEASE:compile
[INFO] | +- (org.springframework:spring-aop:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-beans:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | +- (org.springframework:spring-context:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] | - (org.springframework:spring-core:jar:4.2.6.RELEASE:compile - omitted for duplicate)
[INFO] +- org.springframework.security:spring-security-core:jar:4.2.9.RELEASE:compile
[INFO] | +- aopalliance:aopalliance:jar:1.0:compile
[INFO] | +- org.springframework:spring-aop:jar:4.3.19.RELEASE:compile
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | | - (org.springframework:spring-core:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | +- (org.springframework:spring-beans:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | +- (org.springframework:spring-context:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | +- (org.springframework:spring-core:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | - (org.springframework:spring-expression:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] +- org.springframework.security:spring-security-test:jar:4.2.9.RELEASE:compile
[INFO] | +- (org.springframework.security:spring-security-core:jar:4.2.9.RELEASE:compile - omitted for duplicate)
[INFO] | +- org.springframework.security:spring-security-web:jar:4.2.9.RELEASE:compile
[INFO] | | +- (aopalliance:aopalliance:jar:1.0:compile - omitted for duplicate)
[INFO] | | +- (org.springframework.security:spring-security-core:jar:4.2.9.RELEASE:compile - omitted for duplicate)
[INFO] | | +- (org.springframework:spring-beans:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | | +- (org.springframework:spring-context:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | | +- (org.springframework:spring-core:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | | +- (org.springframework:spring-expression:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | | - (org.springframework:spring-web:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | +- (org.springframework:spring-core:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] | - (org.springframework:spring-test:jar:4.3.19.RELEASE:compile - omitted for conflict with 4.2.6.RELEASE)
[INFO] +- org.apache.geronimo.specs:geronimo-servlet_3.0_spec:jar:1.0:provided
[INFO] +- junit:junit:jar:4.12:test
[INFO] | - (org.hamcrest:hamcrest-core:jar:1.3:test - omitted for duplicate)
[INFO] +- commons-io:commons-io:jar:2.4:test
[INFO] +- org.assertj:assertj-core:jar:1.7.0:test
[INFO] +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.11:test
[INFO] | - (org.codehaus.jackson:jackson-core-asl:jar:1.9.11:test - omitted for duplicate)
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.11:test
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:test
[INFO] | +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:test
[INFO] | - com.fasterxml.jackson.core:jackson-core:jar:2.9.7:test
[INFO] +- org.powermock:powermock-reflect:jar:1.5.6:test
[INFO] | - org.objenesis:objenesis:jar:2.1:test
[INFO] - org.springframework.restdocs:spring-restdocs-mockmvc:jar:1.0.0.RELEASE:test
[INFO] +- (org.springframework:spring-test:jar:4.1.7.RELEASE:test - omitted for conflict with 4.2.6.RELEASE)
[INFO] - org.springframework.restdocs:spring-restdocs-core:jar:1.0.0.RELEASE:test
[INFO] +- (junit:junit:jar:4.12:test - omitted for duplicate)
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:test
[INFO] +- (org.springframework:spring-webmvc:jar:4.1.7.RELEASE:test - omitted for conflict with 4.2.6.RELEASE)
[INFO] - (com.fasterxml.jackson.core:jackson-databind:jar:2.9.7:test - version managed from 2.4.6.1; omitted for duplicate)
The text was updated successfully, but these errors were encountered: