Skip to content

Commit

Permalink
Update third-party lib dependencies and fix minor issues
Browse files Browse the repository at this point in the history
  • Loading branch information
cyb3r4nt committed Mar 12, 2024
1 parent 9b85747 commit f95dcb7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 30 deletions.
32 changes: 17 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
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 {
Expand All @@ -15,8 +17,8 @@ buildscript {
}

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")
}
}

Expand Down Expand Up @@ -67,7 +69,7 @@ test {
}

jacoco {
toolVersion = "0.8.5"
toolVersion = "0.8.11"
}

jacocoTestReport {
Expand Down Expand Up @@ -114,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'
}
testRuntimeOnly 'org.apache.logging.log4j:log4j-slf4j-impl:2.19.0'
testRuntimeOnly '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'

}

Expand Down
2 changes: 1 addition & 1 deletion publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/com/googlecode/jsonrpc4j/JsonRpcHttpAsyncClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/googlecode/jsonrpc4j/JsonRpcServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,24 @@
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;

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();
}
Expand Down

0 comments on commit f95dcb7

Please sign in to comment.