Skip to content

Commit

Permalink
Merge remote-tracking branch 'dubbo/3.3' into 3.3
Browse files Browse the repository at this point in the history
# Conflicts:
#	dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/config/HttpClientConfig.java
#	dubbo-remoting/dubbo-remoting-http/src/main/java/org/apache/dubbo/remoting/http/restclient/OKHttpRestClient.java
  • Loading branch information
wcy666103 committed May 8, 2024
2 parents b313bf7 + 487fa4f commit 4e97f43
Show file tree
Hide file tree
Showing 19 changed files with 101 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ target/
.settings/
.project
.classpath
.externalToolBuilders
maven-eclipse.xml

# idea ignore
.idea/
Expand Down
10 changes: 5 additions & 5 deletions dubbo-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@
<properties>
<!-- Common libs -->
<!-- <spring_version>4.3.30.RELEASE</spring_version> -->
<spring_version>5.3.33</spring_version>
<spring_version>5.3.34</spring_version>
<spring_security_version>5.8.12</spring_security_version>
<javassist_version>3.30.2-GA</javassist_version>
<byte-buddy_version>1.14.13</byte-buddy_version>
<byte-buddy_version>1.14.14</byte-buddy_version>
<netty_version>3.2.10.Final</netty_version>
<netty4_version>4.1.109.Final</netty4_version>
<httpclient_version>4.5.14</httpclient_version>
<httpcore_version>4.4.16</httpcore_version>
<fastjson_version>1.2.83</fastjson_version>
<fastjson2_version>2.0.48</fastjson2_version>
<fastjson2_version>2.0.49</fastjson2_version>
<zookeeper_version>3.7.2</zookeeper_version>
<curator_version>5.1.0</curator_version>
<curator_test_version>2.12.0</curator_test_version>
Expand All @@ -119,7 +119,7 @@
<snakeyaml_version>2.2</snakeyaml_version>
<commons_lang3_version>3.14.0</commons_lang3_version>
<envoy_api_version>0.1.35</envoy_api_version>
<micrometer.version>1.12.4</micrometer.version>
<micrometer.version>1.12.5</micrometer.version>
<opentelemetry.version>1.26.0</opentelemetry.version>
<zipkin-reporter.version>2.16.4</zipkin-reporter.version>
<micrometer-tracing.version>1.2.5</micrometer-tracing.version>
Expand Down Expand Up @@ -175,7 +175,7 @@
<sofa_registry_version>5.4.3</sofa_registry_version>
<metrics_version>2.0.6</metrics_version>
<gson_version>2.10.1</gson_version>
<jackson_version>2.17.0</jackson_version>
<jackson_version>2.17.1</jackson_version>
<mortbay_jetty_version>6.1.26</mortbay_jetty_version>
<portlet_version>2.0</portlet_version>
<maven_flatten_version>1.6.0</maven_flatten_version>
Expand Down
2 changes: 1 addition & 1 deletion dubbo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.12.0</version>
<version>3.13.0</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,13 @@ protected final HttpOutputMessage buildMessage(Object data) throws Throwable {
data = ((HttpResult<?>) data).getBody();
}
HttpOutputMessage outputMessage = encodeHttpOutputMessage(data);
preOutputMessage(outputMessage);
responseEncoder.encode(outputMessage.getBody(), data);
try {
preOutputMessage(outputMessage);
responseEncoder.encode(outputMessage.getBody(), data);
} catch (Throwable t) {
outputMessage.close();
throw t;
}
return outputMessage;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
*/
package org.apache.dubbo.remoting.http12;

import java.io.IOException;
import java.io.InputStream;

public interface HttpInputMessage {
public interface HttpInputMessage extends AutoCloseable {

InputStream getBody();

@Override
default void close() throws IOException {
getBody().close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@
package org.apache.dubbo.remoting.http12;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public interface HttpOutputMessage {
public interface HttpOutputMessage extends AutoCloseable {

HttpOutputMessage EMPTY_MESSAGE = new HttpOutputMessage() {

Expand All @@ -32,4 +33,9 @@ public OutputStream getBody() {
};

OutputStream getBody();

@Override
default void close() throws IOException {
getBody().close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dubbo.remoting.http12.HttpInputMessage;
import org.apache.dubbo.remoting.http12.RequestMetadata;

import java.io.IOException;
import java.io.InputStream;

public class DefaultHttp1Request implements Http1Request {
Expand Down Expand Up @@ -52,4 +53,9 @@ public String method() {
public String path() {
return httpMetadata.path();
}

@Override
public void close() throws IOException {
httpInputMessage.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.dubbo.remoting.http12.HttpInputMessage;
import org.apache.dubbo.remoting.http12.HttpMetadata;

import java.io.IOException;
import java.io.InputStream;

public class DefaultHttp1Response implements HttpMetadata, HttpInputMessage {
Expand All @@ -42,4 +43,9 @@ public InputStream getBody() {
public HttpHeaders headers() {
return httpMetadata.headers();
}

@Override
public void close() throws IOException {
httpInputMessage.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@

import org.apache.dubbo.remoting.http12.HttpOutputMessage;

import java.io.IOException;
import java.io.OutputStream;

import io.netty.buffer.ByteBufOutputStream;

public class Http1OutputMessage implements HttpOutputMessage {

private final OutputStream outputStream;
Expand All @@ -32,4 +35,12 @@ public Http1OutputMessage(OutputStream outputStream) {
public OutputStream getBody() {
return outputStream;
}

@Override
public void close() throws IOException {
if (outputStream instanceof ByteBufOutputStream) {
((ByteBufOutputStream) outputStream).buffer().release();
}
outputStream.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
*/
package org.apache.dubbo.remoting.http12.h2;

import java.io.IOException;
import java.io.OutputStream;

import io.netty.buffer.ByteBufOutputStream;

public class Http2OutputMessageFrame implements Http2OutputMessage {

private final OutputStream body;
Expand All @@ -42,6 +45,14 @@ public OutputStream getBody() {
return body;
}

@Override
public void close() throws IOException {
if (body instanceof ByteBufOutputStream) {
((ByteBufOutputStream) body).buffer().release();
}
body.close();
}

@Override
public boolean isEndStream() {
return endStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,9 @@ public void onData(MESSAGE message) {
doOnData(message);
} catch (Throwable t) {
logError(t);
onError(t);
onError(message, t);
} finally {
onFinally(message);
}
});
}
Expand Down Expand Up @@ -184,6 +186,18 @@ protected void onError(Throwable throwable) {
throw new HttpStatusException(HttpStatus.INTERNAL_SERVER_ERROR.getCode(), throwable);
}

protected void onError(MESSAGE message, Throwable throwable) {
onError(throwable);
}

protected void onFinally(MESSAGE message) {
try {
message.close();
} catch (Exception e) {
onError(e);
}
}

protected RpcInvocation buildRpcInvocation(RpcInvocationBuildContext context) {
MethodDescriptor methodDescriptor = context.getMethodDescriptor();
if (methodDescriptor == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.apache.dubbo.remoting.http12.exception.UnimplementedException;
import org.apache.dubbo.remoting.http12.h2.H2StreamChannel;
import org.apache.dubbo.remoting.http12.h2.Http2Header;
import org.apache.dubbo.remoting.http12.h2.Http2InputMessage;
import org.apache.dubbo.remoting.http12.h2.Http2TransportListener;
import org.apache.dubbo.remoting.http12.message.MethodMetadata;
import org.apache.dubbo.remoting.http12.message.StreamingDecoder;
Expand Down Expand Up @@ -122,6 +123,19 @@ protected RpcInvocation onBuildRpcInvocationCompletion(RpcInvocation invocation)
return invocation;
}

@Override
protected void onError(Http2InputMessage message, Throwable throwable) {
try {
message.close();
} catch (Exception e) {
throwable.addSuppressed(e);
}
onError(throwable);
}

@Override
protected void onFinally(Http2InputMessage message) {}

@Override
protected GrpcStreamingDecoder getStreamingDecoder() {
return (GrpcStreamingDecoder) super.getStreamingDecoder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ protected Executor initializeExecutor(Http2Header metadata) {
return new SerializingExecutor(executorSupport.getExecutor(metadata));
}

@Override
protected void doOnMetadata(Http2Header metadata) {
if (metadata.isEndStream()) {
if (!HttpMethods.supportBody(metadata.method())) {
Expand Down Expand Up @@ -164,7 +165,7 @@ protected void onMetadataCompletion(Http2Header metadata) {
@Override
protected void onDataCompletion(Http2InputMessage message) {
if (message.isEndStream()) {
serverCallListener.onComplete();
getStreamingDecoder().close();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
</modules>

<properties>
<micrometer.version>1.12.4</micrometer.version>
<micrometer.version>1.12.5</micrometer.version>
<micrometer-tracing.version>1.2.5</micrometer-tracing.version>
<opentelemetry.version>1.34.1</opentelemetry.version>
<zipkin-reporter.version>2.17.2</zipkin-reporter.version>
Expand Down
2 changes: 1 addition & 1 deletion dubbo-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<properties>
<spring-boot.version>2.7.18</spring-boot.version>
<!-- Spring boot buddy is lower than the delivery dependency package version and can only show the defined dependency version -->
<byte-buddy.version>1.14.13</byte-buddy.version>
<byte-buddy.version>1.14.14</byte-buddy.version>
<mockito_version>4.11.0</mockito_version>
</properties>

Expand Down
2 changes: 1 addition & 1 deletion dubbo-test/dubbo-test-spring3.2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<properties>
<skip_maven_deploy>true</skip_maven_deploy>
<spring_version>5.3.33</spring_version>
<spring_version>5.3.34</spring_version>
</properties>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion dubbo-test/dubbo-test-spring4.1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<properties>
<skip_maven_deploy>true</skip_maven_deploy>
<spring_version>5.3.33</spring_version>
<spring_version>5.3.34</spring_version>
</properties>

<dependencyManagement>
Expand Down
2 changes: 1 addition & 1 deletion dubbo-test/dubbo-test-spring4.2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<properties>
<skip_maven_deploy>true</skip_maven_deploy>
<spring_version>5.3.33</spring_version>
<spring_version>5.3.34</spring_version>
</properties>

<dependencyManagement>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
<jacoco.skip>true</jacoco.skip>

<!-- Maven plugins -->
<maven_jar_version>3.3.0</maven_jar_version>
<maven_jar_version>3.4.1</maven_jar_version>
<maven_surefire_version>3.2.5</maven_surefire_version>
<maven_failsafe_version>3.2.5</maven_failsafe_version>
<maven_deploy_version>2.8.2</maven_deploy_version>
Expand Down Expand Up @@ -280,7 +280,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<version>3.5.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
Expand Down

0 comments on commit 4e97f43

Please sign in to comment.