diff --git a/build.gradle b/build.gradle index 37bc99c..1e0b3cf 100644 --- a/build.gradle +++ b/build.gradle @@ -1,23 +1,24 @@ buildscript { ext { - set("jacksonVersion", "2.13.4") - set("springVersion", "5.3.23") - set("springBotVersion", "2.7.4") - set("jettyVersion", "9.4.49.v20220914") - set("slf4jVersion", "2.0.3") + set("jacksonVersion", "2.16.1") + // Versions 6.0.0 and above no longer support Java 1.8 + set("springVersion", "5.3.32") + // Versions 3.0.0 and above no longer support Java 1.8 + set("springBootVersion", "2.7.18") + set("jettyVersion", "9.4.54.v20240208") + set("slf4jVersion", "2.0.12") } repositories { gradlePluginPortal() mavenCentral() - jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { - classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3" - classpath("com.adarshr:gradle-test-logger-plugin:1.6.0") + classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" + classpath("com.adarshr:gradle-test-logger-plugin:3.2.0") } } @@ -29,7 +30,6 @@ repositories { mavenLocal() gradlePluginPortal() mavenCentral() - jcenter() } apply plugin: "java" @@ -41,8 +41,10 @@ description = """ This project aims to provide the facility to easily implement JSON-RPC for the java programming language. """ -sourceCompatibility = 1.8 -targetCompatibility = 1.8 +java { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} compileJava { options.encoding = 'UTF-8' @@ -67,23 +69,27 @@ test { } jacoco { - toolVersion = "0.8.5" + toolVersion = "0.8.11" } jacocoTestReport { dependsOn test reports { - xml.enabled true - csv.enabled true - html.enabled true + xml.required = true + csv.required = true + html.required = true } } java { registerFeature('servletSupport') { + // TODO: create a separate sourceSet for this library feature. + // Gradle is planning to break this in v9.0 usingSourceSet(sourceSets.main) } registerFeature('springSupport') { + // TODO: create a separate sourceSet for this library feature. + // Gradle is planning to break this in v9.0 usingSourceSet(sourceSets.main) } } @@ -110,23 +116,23 @@ dependencies { springSupportImplementation "org.springframework:spring-web:${springVersion}" springSupportImplementation "org.springframework:spring-webmvc:${springVersion}" - implementation 'commons-codec:commons-codec:1.15' - implementation 'org.apache.httpcomponents:httpcore-nio:4.4.15' + implementation 'commons-codec:commons-codec:1.16.1' + implementation 'org.apache.httpcomponents:httpcore-nio:4.4.16' testImplementation 'junit:junit:4.13.2' - testImplementation 'org.easymock:easymock:4.3' - testImplementation("org.springframework.boot:spring-boot-starter-web:${springBotVersion}") { + testImplementation 'org.easymock:easymock:5.2.0' + testImplementation("org.springframework.boot:spring-boot-starter-web:${springBootVersion}") { exclude module: 'logback-classic' } - testImplementation "org.springframework.boot:spring-boot-starter-test:${springBotVersion}" + testImplementation "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" testImplementation("org.eclipse.jetty:jetty-server:${jettyVersion}") { exclude module: 'javax.servlet' } testImplementation("org.eclipse.jetty:jetty-servlet:${jettyVersion}") { exclude module: 'org.eclipse.jetty.orbit' } - testRuntime 'org.apache.logging.log4j:log4j-slf4j-impl:2.19.0' - testRuntime 'org.apache.logging.log4j:log4j-core:2.19.0' + testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.23.0' + testRuntimeOnly 'org.apache.logging.log4j:log4j-core:2.23.0' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ed188de..f009724 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ #Mon Oct 07 19:30:35 PDT 2019 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStorePath=wrapper/dists diff --git a/publishing.gradle b/publishing.gradle index 2f7998b..ac16890 100644 --- a/publishing.gradle +++ b/publishing.gradle @@ -8,7 +8,7 @@ buildscript { gradlePluginPortal() } dependencies { - classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0' + classpath 'io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0' classpath 'gradle.plugin.net.wooga.gradle:atlas-github:1.0.1' classpath 'net.researchgate:gradle-release:2.7.0' classpath 'org.ajoberstar:grgit:2.3.0' diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java index 9e195ff..7e25d17 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcBasicServer.java @@ -279,6 +279,8 @@ protected Class[] getHandlerInterfaces(final String serviceName) { * * @param node the {@link JsonNode} * @return the {@link JsonResponse} instance + * @throws JsonParseException when {@link JsonNode} read fails + * @throws JsonMappingException when {@link JsonNode} read fails */ protected JsonResponse handleJsonNodeRequest(final JsonNode node) throws JsonParseException, JsonMappingException { diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java index 0b712e9..e889103 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java @@ -412,29 +412,33 @@ private void initialize() { pool = new BasicNIOConnPool(ioReactor, nioConnFactory, Integer.getInteger("com.googlecode.jsonrpc4j.async.connect.timeout", 30000)); pool.setDefaultMaxPerRoute(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.route", 500)); pool.setMaxTotal(Integer.getInteger("com.googlecode.jsonrpc4j.async.max.inflight.total", 500)); - - Thread t = new Thread(new Runnable() { - @Override - public void run() { + + Thread t = new Thread( + () -> { try { HttpAsyncRequestExecutor protocolHandler = new HttpAsyncRequestExecutor(); - IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch(protocolHandler, sslContext, connectionConfig); + IOEventDispatch ioEventDispatch = new DefaultHttpClientIODispatch<>( + protocolHandler, + sslContext, + connectionConfig + ); ioReactor.execute(ioEventDispatch); } catch (InterruptedIOException ex) { System.err.println("Interrupted"); } catch (IOException e) { System.err.println("I/O error: " + e.getMessage()); } - } - }, "jsonrpc4j HTTP IOReactor"); - + }, + "jsonrpc4j HTTP IOReactor" + ); + t.setDaemon(true); t.start(); HttpProcessor httpProcessor = new ImmutableHttpProcessor(new RequestContent(), new RequestTargetHost(), new RequestConnControl(), new RequestUserAgent(), new RequestExpectContinue(false)); requester = new HttpAsyncRequester(httpProcessor, new DefaultConnectionReuseStrategy()); } - + private IOReactorConfig.Builder createConfig() { IOReactorConfig.Builder config = IOReactorConfig.custom(); config = config.setSoTimeout(Integer.getInteger("com.googlecode.jsonrpc4j.async.socket.timeout", 30000)); diff --git a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcServer.java b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcServer.java index 4158242..906c029 100644 --- a/src/main/java/com/googlecode/jsonrpc4j/JsonRpcServer.java +++ b/src/main/java/com/googlecode/jsonrpc4j/JsonRpcServer.java @@ -104,7 +104,11 @@ private InputStream getRequestStream(ResourceRequest request) throws IOException } private static InputStream createInputStream(ResourceRequest request) throws IOException { - return createInputStream(request.getParameter(METHOD), request.getParameter(ID), request.getParameter(PARAMS)); + return createInputStream( + request.getRenderParameters().getValue(METHOD), + request.getRenderParameters().getValue(ID), + request.getRenderParameters().getValue(PARAMS) + ); } /** diff --git a/src/test/java/com/googlecode/jsonrpc4j/integration/HttpCodeTest.java b/src/test/java/com/googlecode/jsonrpc4j/integration/HttpCodeTest.java index e77e17f..14c7a95 100644 --- a/src/test/java/com/googlecode/jsonrpc4j/integration/HttpCodeTest.java +++ b/src/test/java/com/googlecode/jsonrpc4j/integration/HttpCodeTest.java @@ -14,6 +14,7 @@ import java.net.MalformedURLException; import static org.hamcrest.CoreMatchers.anyOf; +import static org.hamcrest.CoreMatchers.endsWith; import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.startsWith; @@ -21,13 +22,16 @@ public class HttpCodeTest extends BaseRestTest { @Test public void http405OnInvalidUrl() throws MalformedURLException { - expectedEx.expectMessage(anyOf( + expectedEx.expectMessage( + anyOf( equalTo("405 HTTP method POST is not supported by this URL"), equalTo("404 Not Found"), equalTo("HTTP method POST is not supported by this URL"), - equalTo("Method Not Allowed"), - startsWith("Server returned HTTP response code: 405 for URL: http://127.0.0.1"))); - expectedEx.expect(Exception.class); + startsWith("Server returned HTTP response code: 405 for URL: http://127.0.0.1"), + endsWith("Method Not Allowed") + ) + ); + expectedEx.expect(JsonRpcClientException.class); FakeServiceInterface service = ProxyUtil.createClientProxy(FakeServiceInterface.class, getClient("error")); service.doSomething(); }