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

fix spring 6 bean configuration error #674

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 7 additions & 11 deletions feign-reactor-benchmarks/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<artifactId>feign-reactor-benchmarks</artifactId>

<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<jmh.version>1.37</jmh.version>
</properties>

Expand Down Expand Up @@ -51,18 +51,14 @@
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-client</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-client</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-http-client-transport</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import jakarta.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.http2.server.HTTP2CServerConnectionFactory;
import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.server.*;
import org.eclipse.jetty.server.handler.AbstractHandler;
import org.eclipse.jetty.util.Callback;
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.springframework.web.reactive.function.client.WebClient;
import reactivefeign.java11.Java11ReactiveFeign;
Expand All @@ -29,10 +29,12 @@

import java.io.IOException;
import java.lang.reflect.ParameterizedType;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

import static reactivefeign.benchmarks.BenchmarkUtils.readJsonFromFile;
import static reactivefeign.benchmarks.BenchmarkUtils.readJsonFromFileAsBytes;
Expand Down Expand Up @@ -159,27 +161,41 @@ public rx.Observable<Void> handle(HttpServerRequest<ByteBuf> request,
}

private Server jettyH2c(int port){
Server serverJetty = new Server();

serverJetty.setHandler(new AbstractHandler(){
Server serverJetty = new Server(port);

// serverJetty.setHandler(new AbstractHandler(){
// @Override
// public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
// request.getInputStream().skip(Integer.MAX_VALUE);
// if(target.equals(PATH_WITH_PAYLOAD)){
// response.addHeader("Content-Type", "application/json");
// response.getOutputStream().write(responseJson);
// response.getOutputStream().flush();
// }
// baseRequest.setHandled(true);
// }
// });


serverJetty.setHandler(new AbstractHandler() {
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException {
request.getInputStream().skip(Integer.MAX_VALUE);
if(target.equals(PATH_WITH_PAYLOAD)){
response.addHeader("Content-Type", "application/json");
response.getOutputStream().write(responseJson);
response.getOutputStream().flush();
public boolean handle(Request request, Response response, Callback callback) throws Exception {
request.read().skip(Integer.MAX_VALUE);
callback.succeeded();
if(request.getContext().getContextPath().equals(PATH_WITH_PAYLOAD)) {
response.getHeaders().add("Content-Type", "application/json");
ByteBuffer buffer = ByteBuffer.wrap(responseJson);
response.write(true, buffer, callback);
}
baseRequest.setHandled(true);


return true;
}
});

//setup h2c
HttpConfiguration httpConfig = new HttpConfiguration();
ServerConnector connectorH2c = new ServerConnector(serverJetty,
new HttpConnectionFactory(httpConfig),
new HTTP2CServerConnectionFactory(httpConfig)
);
ServerConnector connectorH2c = new ServerConnector(serverJetty, new HttpConnectionFactory(httpConfig));
connectorH2c.setPort(port);
serverJetty.addConnector(connectorH2c);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ public long retryDelay(Throwable error, int attemptNo) {
if(periodInMs > 0) {
long delay;
Date retryAfter;

// "Retry-After" header set
if (error instanceof RetryableException
&& (retryAfter = ((RetryableException) error)
.retryAfter()) != null) {
if (error instanceof RetryableException && (retryAfter = new Date(((RetryableException) error).retryAfter())) != null) {
delay = retryAfter.getTime() - clock.millis();
delay = Math.min(delay, periodInMs);
delay = Math.max(delay, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public void shouldThrowOnStatusCode() {
return new RetryableException(
response.status(),
"Should retry on next node",
httpMethod, null, request);
httpMethod, null, 0L, request);
}),
throwOnStatus(
status -> status == SC_UNAUTHORIZED,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.Disabled;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public void shouldTakeIntoAccountRetryAfter(){
new Date(currentTime + delay), request), 1);
assertThat(retryDelay).isEqualTo(delay);

retryDelay = retryPolicy.retryDelay(new RetryableException(-1, "error msg", Request.HttpMethod.GET,
null, request), 1);
retryDelay = retryPolicy.retryDelay(new RetryableException(-1, "error msg", Request.HttpMethod.GET, null, 0L, request), 1);
assertThat(retryDelay).isEqualTo(backoff);
}

Expand Down
43 changes: 24 additions & 19 deletions feign-reactor-java11/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
</dependency>

<!--to get QueuedSinglePublisher-->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-reactive-httpclient</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.eclipse.jetty</groupId>-->
<!-- <artifactId>jetty-reactive-httpclient</artifactId>-->
<!-- </dependency>-->

<!-- Tests -->
<dependency>
Expand Down Expand Up @@ -59,34 +59,39 @@
</dependency>

<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<scope>test</scope>
<groupId>org.wiremock</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>${wiremock.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-servlet</artifactId>
<version>${jetty.version}</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.ee10/jetty-ee10-webapp -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
<groupId>org.eclipse.jetty.ee10</groupId>
<artifactId>jetty-ee10-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<scope>test</scope>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-reactive-httpclient</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
<artifactId>jetty-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-client-transport</artifactId>
<version>${jetty.version}</version>
</dependency>


<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down
53 changes: 33 additions & 20 deletions feign-reactor-jetty/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -17,17 +18,8 @@
<artifactId>feign-reactor-core</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-client</artifactId>
<optional>true</optional>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-http-client-transport</artifactId>
<optional>true</optional>
</dependency>


<dependency>
<groupId>org.eclipse.jetty</groupId>
Expand Down Expand Up @@ -74,33 +66,54 @@
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-jre8-standalone</artifactId>
<scope>test</scope>
<version>3.0.1</version>
</dependency>


<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
<scope>test</scope>
<version>12.0.9</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-http -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-servlet</artifactId>
<scope>test</scope>
<artifactId>jetty-http</artifactId>
<version>12.0.9</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<scope>test</scope>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-reactive-httpclient</artifactId>
<version>4.0.3</version>
</dependency>






<!-- https://mvnrepository.com/artifact/org.eclipse.jetty/jetty-server -->
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<scope>test</scope>
<artifactId>jetty-server</artifactId>
<version>12.0.9</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.eclipse.jetty.http2/jetty-http2-client-transport -->
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>jetty-http2-client-transport</artifactId>
<version>${jetty.version}</version>
</dependency>






<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpProxy;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2;
import reactivefeign.ReactiveFeign;
import reactivefeign.ReactiveFeignBuilder;
import reactivefeign.ReactiveOptions;
import reactivefeign.client.ReactiveHttpClientFactory;
import reactivefeign.jetty.client.JettyReactiveHttpClient;

import javax.net.ssl.SSLServerSocketFactory;

/**
* Reactive Jetty client based implementation of reactive Feign
*
Expand All @@ -39,10 +41,12 @@ public static <T> Builder<T> builder() {
return builder(useHttp2 -> {
try {
if(useHttp2){

HTTP2Client h2Client = new HTTP2Client();
h2Client.setSelectors(1);
HttpClientTransportOverHTTP2 transport = new HttpClientTransportOverHTTP2(h2Client);


HttpClient httpClient = new HttpClient(transport);
httpClient.start();
return httpClient;
Expand Down
Loading
Loading