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

org.json implementation used by spring-boot-starter-test clashes with the commonly used one #9630

Closed
xtreye opened this issue Jun 29, 2017 · 8 comments
Labels
status: duplicate A duplicate of another issue

Comments

@xtreye
Copy link

xtreye commented Jun 29, 2017

spring-boot-starter-test eventually depends on non-standard org.json implementation com.vaadin.external.google:android-json which clashes with the commonly used org.json:json.

The symptom is exception

java.lang.NoSuchMethodError: org.json.JSONObject.stringToValue(Ljava/lang/String;)Ljava/lang/Object;

when XML.toJSONObject(String) is called inside a test. Production code works fine since does not depend on spring-boot-starter-test.

It is not possible to accept this and use com.vaadin.external.google:android-json implementation in a project because it has different interface and moreover lacks XML convertion functionality. Also, Spring Boot is not an Android framework to have such dependency. Thus, I consider this an bug to be fixed.

The bug is reproducible with the latest versions 1.5.2 to 1.5.4.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 29, 2017
@xtreye
Copy link
Author

xtreye commented Jun 29, 2017

Workaround is dependency exclusion:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
    <exclusions>
        <exclusion>
            <groupId>com.vaadin.external.google</groupId>
            <artifactId>android-json</artifactId>
        </exclusion>
    </exclusions>
</dependency>

@wilkinsona
Copy link
Member

With 1.5.4 there should have been a warning generated in the logs (see #9248). Did it not appear?

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Jun 29, 2017
@xtreye
Copy link
Author

xtreye commented Jun 29, 2017

Yes, it appears, now I have noticed it. The ticket you mentioned describes my issue so they could be merged.

This "The Software shall be used for Good, not Evil." conflict is a really weird stuff. Spring Boot should at least give an ability to choose the implementation. The Android lib is outdated anyway.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jun 29, 2017
@wilkinsona
Copy link
Member

Thanks for following up.

@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged labels Jun 29, 2017
@xtreye
Copy link
Author

xtreye commented Jun 29, 2017

NP, but I do not feel that notification about the conflict actually fixes the issue.

I have informed the author of the JSON-java: stleary/JSON-java#353

This misconception is to be dealt with, not avoided.

@wilkinsona
Copy link
Member

wilkinsona commented Jun 29, 2017

I don't think there's any misconception here. The dependency that we care about is the org.json:json the source for which is https://github.com/stleary/JSON-java. Its README says:

The license includes this restriction: "The software shall be used for good,
not evil." If your conscience cannot live with that, then choose a different
package.

Use of the JSON checker test suite makes no difference. The project's FAQ makes it clear that the licence isn't going to change.

The dependency that we use instead, com.vaadin.external.google:android-json, doesn't really have anything to do with Android. It's a clean-room reimplementation of (a relatively old version of) org.json:json. It just happens to have been written by the Android team.

The situation that we're in here is undoubtedly unfortunate, but, until other libraries more away from org.json:json, there's not much we can do.

@xtreye
Copy link
Author

xtreye commented Jun 29, 2017

I see. So the long-term solution is to fork and develop the original library or persuade the developer that his position is not acceptable. I just wonder why nobody cares.

Thanks anyway.

@xtreye
Copy link
Author

xtreye commented Jun 29, 2017

Sorry, I feel I have given the wrong link about the RapidJSON. My bad. As long as nothing specific this thread has, you may want to remove it at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

3 participants