taskadapter / redmine-java-api

Redmine Java API
Apache License 2.0
270 stars 163 forks source link

changed org.json:json dependency: version 20090211 -> 20190722 #336

Closed MikhailKlimenko closed 4 years ago

MikhailKlimenko commented 4 years ago

Hi, the current version of the library conflicts with the new version that is installed in the transitive library, we had to update the version.

alexeyOnGitHub commented 4 years ago

can you please describe the error you see and how the dependency update fixes it?

MikhailKlimenko commented 4 years ago

In my microservice, in addition to the redmine-java-api library 'org.json:json:20090211', there is another library that uses group: 'org.json', name: 'json', version: '20190722', this causes a conflict:

java.util.concurrent.CompletionException: java.lang.NoSuchMethodError: org.json.JSONWriter.(Ljava/io/Writer;)V at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1629) at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: java.lang.NoSuchMethodError: org.json.JSONWriter.(Ljava/io/Writer;)V at com.taskadapter.redmineapi.internal.RedmineJSONBuilder.toSimpleJSON(RedmineJSONBuilder.java:121) at com.taskadapter.redmineapi.internal.Transport.addObject(Transport.java:229) at com.taskadapter.redmineapi.bean.Issue.create(Issue.java:630) at sx.microservices.iae.redmine.controller.RedmineClient.createIssue(RedmineClient.java:172) at sx.microservices.iae.redmine.controller.RedmineClient.lambda$create$0(RedmineClient.java:43) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626) ... 5 more

I solved this problem by adding in my microservice: compile (group: 'org.json', name: 'json', version: '20190722') { transitive = false }

alexeyOnGitHub commented 4 years ago

it is likely that your issue could be solved by excluding the json transitive dependency from this library and explicitly importing the one you need. have you tried this approach?

I do not mind updating dependencies in this project, but need to be careful because resolving one conflict may produce another one, depending on how much the dependency authors cared about backward compatibility. in this case the version number does not give any indication about the library changes, so cannot rely on semantic versioning convention. in other words, there is no information on what other issues this dependency update will cause in other project. also, need to check if the new dependency requires Java 8-10-11-etc

MikhailKlimenko commented 4 years ago

In my case, it helped by adding exclude group: 'org.json' in gradle.

Today I noticed that Redmine 4.1.0 appeared, in library Java-Redmine-API, instead of 200 response comes 204(issue.update()). ERROR java.lang.IllegalArgumentException: Entity may not be null at org.apache.http.util.Args.notNull(Args.java:54)

at org.apache.http.util.EntityUtils.getContentCharSet(EntityUtils.java:159) at com.taskadapter.redmineapi.internal.comm.HttpUtil.getCharset(HttpUtil.java:32) at com.taskadapter.redmineapi.internal.comm.TransportDecoder.processContent(TransportDecoder.java:26) at com.taskadapter.redmineapi.internal.comm.TransportDecoder.processContent(TransportDecoder.java:19) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.BaseCommunicator.sendRequest (BaseCommunicator.java:47) at com.taskadapter.redmineapi.internal.comm.redmine.RedmineAuthenticator.sendRequest(RedmineAuthenticator.java:52) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.BasicSimplifier.sendRequest(BasicSimplifier.java:24) at com.taskadapter.redmineapi.internal.Transport.send (Transport.java:605) at com.taskadapter.redmineapi.internal.Transport.updateObject(Transport.java:283) at com.taskadapter.redmineapi.bean.Issue.update(Issue.java:634) at sx.microservices.iae.redmine.controller.RedmineClient.updateIssue(RedmineClient.java:116) at sx.microservices.iae.redmine.controller.RedmineClient.lambda$update$2(RedmineClient.java:66) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626) at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.The ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Entity may not be null at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:273) at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:280) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1629) at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1618) at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289) at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056) at java.util.concurrent.The ForkJoinPool.runWorker(ForkJoinPool.java:1692) at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157) Caused by: java.lang.IllegalArgumentException: Entity may not be null at org.apache.http.util.Args.notNull(Args.java:54) at org.apache.http.util.EntityUtils.getContentCharSet(EntityUtils.java:159) at com.taskadapter.redmineapi.internal.comm.HttpUtil.getCharset(HttpUtil.java:32) at com.taskadapter.redmineapi.internal.comm.TransportDecoder.processContent(TransportDecoder.java:26) at com.taskadapter.redmineapi.internal.comm.TransportDecoder.processContent(TransportDecoder.java:19) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.ComposingHandler.processContent(ComposingHandler.java:25) at com.taskadapter.redmineapi.internal.comm.BaseCommunicator.sendRequest (BaseCommunicator.java:47) at com.taskadapter.redmineapi.internal.comm.redmine.RedmineAuthenticator.sendRequest(RedmineAuthenticator.java:52) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.FmapCommunicator.sendRequest(FmapCommunicator.java:26) at com.taskadapter.redmineapi.internal.comm.BasicSimplifier.sendRequest(BasicSimplifier.java:24) at com.taskadapter.redmineapi.internal.Transport.send (Transport.java:605) at com.taskadapter.redmineapi.internal.Transport.updateObject(Transport.java:283) at com.taskadapter.redmineapi.bean.Issue.update(Issue.java:634) at sx.microservices.iae.redmine.controller.RedmineClient.updateIssue(RedmineClient.java:138) at sx.microservices.iae.redmine.controller.RedmineClient.lambda$update$2(RedmineClient.java:66) at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1626) ... 5 more

image