Skip to content

Commit

Permalink
Merge branch '3.3' into h3
Browse files Browse the repository at this point in the history
  • Loading branch information
oxsean authored Jun 15, 2024
2 parents a631bc8 + 667f98a commit 94bd696
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 60 deletions.
2 changes: 1 addition & 1 deletion dubbo-dependencies-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
<jaxb_version>2.2.7</jaxb_version>
<activation_version>1.2.0</activation_version>
<test_container_version>1.19.8</test_container_version>
<hessian_lite_version>4.0.0</hessian_lite_version>
<hessian_lite_version>4.0.1</hessian_lite_version>
<swagger_version>1.6.14</swagger_version>

<snappy_java_version>1.1.10.5</snappy_java_version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ protected void doOnCompleted(Throwable throwable) {
if (httpMetadata == null) {
return;
}
if (!headerSent) {
HttpHeaders headers = httpMetadata.headers();
headers.set(HttpHeaderNames.STATUS.getName(), resolveStatusCode(throwable));
headers.set(HttpHeaderNames.CONTENT_TYPE.getName(), responseEncoder.contentType());
}
trailersCustomizer.accept(httpMetadata.headers(), throwable);
getHttpChannel().writeHeader(httpMetadata);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ protected void onUnary() {}

@Override
protected void onMetadataCompletion(Http2Header metadata) {
super.onMetadataCompletion(metadata);
processGrpcHeaders(metadata);
super.onMetadataCompletion(metadata);
}

private void processGrpcHeaders(Http2Header metadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,10 @@
import org.apache.dubbo.common.io.StreamUtils;
import org.apache.dubbo.common.threadpool.manager.ExecutorRepository;
import org.apache.dubbo.common.threadpool.serial.SerializingExecutor;
import org.apache.dubbo.remoting.Constants;
import org.apache.dubbo.remoting.http12.HttpMethods;
import org.apache.dubbo.remoting.http12.h2.CancelStreamException;
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.Http2InputMessageFrame;
import org.apache.dubbo.remoting.http12.h2.Http2ServerChannelObserver;
import org.apache.dubbo.remoting.http12.h2.Http2TransportListener;
import org.apache.dubbo.remoting.http12.message.DefaultListeningDecoder;
Expand Down Expand Up @@ -58,8 +55,6 @@
public class GenericHttp2ServerTransportListener extends AbstractServerTransportListener<Http2Header, Http2InputMessage>
implements Http2TransportListener {

private static final Http2InputMessage END_MESSAGE = new Http2InputMessageFrame(StreamUtils.EMPTY, true);

private final ExecutorSupport executorSupport;
private final StreamingDecoder streamingDecoder;
private final FrameworkModel frameworkModel;
Expand Down Expand Up @@ -94,18 +89,6 @@ 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())) {
super.doOnMetadata(metadata);
doOnData(END_MESSAGE);
}
return;
}
super.doOnMetadata(metadata);
}

@Override
protected HttpMessageListener buildHttpMessageListener() {
RpcInvocationBuildContext context = getContext();
Expand Down Expand Up @@ -189,6 +172,9 @@ protected void initializeAltSvc(URL url) {
protected void onMetadataCompletion(Http2Header metadata) {
serverChannelObserver.setResponseEncoder(getContext().getHttpMessageEncoder());
serverChannelObserver.request(1);
if (metadata.isEndStream()) {
getStreamingDecoder().close();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,67 +20,50 @@
import org.apache.dubbo.aot.api.ReflectionTypeDescriberRegistrar;
import org.apache.dubbo.aot.api.TypeDescriber;

import java.net.URL;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
import java.util.Properties;
import java.util.Set;

import com.alibaba.com.caucho.hessian.io.BigDecimalDeserializer;
import com.alibaba.com.caucho.hessian.io.FileDeserializer;
import com.alibaba.com.caucho.hessian.io.HessianRemote;
import com.alibaba.com.caucho.hessian.io.LocaleSerializer;
import com.alibaba.com.caucho.hessian.io.ObjectNameDeserializer;
import com.alibaba.com.caucho.hessian.io.StringValueSerializer;
import com.alibaba.com.caucho.hessian.io.java8.DurationSerializer;
import com.alibaba.com.caucho.hessian.io.java8.InstantSerializer;
import com.alibaba.com.caucho.hessian.io.java8.LocalDateSerializer;
import com.alibaba.com.caucho.hessian.io.java8.LocalDateTimeSerializer;
import com.alibaba.com.caucho.hessian.io.java8.LocalTimeSerializer;
import com.alibaba.com.caucho.hessian.io.java8.MonthDaySerializer;
import com.alibaba.com.caucho.hessian.io.java8.OffsetDateTimeSerializer;
import com.alibaba.com.caucho.hessian.io.java8.OffsetTimeSerializer;
import com.alibaba.com.caucho.hessian.io.java8.PeriodSerializer;
import com.alibaba.com.caucho.hessian.io.java8.YearMonthSerializer;
import com.alibaba.com.caucho.hessian.io.java8.YearSerializer;
import com.alibaba.com.caucho.hessian.io.java8.ZoneIdSerializer;
import com.alibaba.com.caucho.hessian.io.java8.ZoneOffsetSerializer;
import com.alibaba.com.caucho.hessian.io.java8.ZonedDateTimeSerializer;

public class HessianReflectionTypeDescriberRegistrar implements ReflectionTypeDescriberRegistrar {

@Override
public List<TypeDescriber> getTypeDescribers() {
List<TypeDescriber> typeDescribers = new ArrayList<>();
typeDescribers.add(buildTypeDescriberWithDeclared(BigDecimalDeserializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(FileDeserializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(HessianRemote.class));
typeDescribers.add(buildTypeDescriberWithDeclared(LocaleSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(ObjectNameDeserializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(StringValueSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(DurationSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(InstantSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(LocalDateSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(LocalDateTimeSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(LocalTimeSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(MonthDaySerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(OffsetDateTimeSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(OffsetTimeSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(PeriodSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(YearMonthSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(YearSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(ZoneIdSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(ZoneOffsetSerializer.class));
typeDescribers.add(buildTypeDescriberWithDeclared(ZonedDateTimeSerializer.class));

loadFile("META-INF/dubbo/hessian/deserializers", typeDescribers);
loadFile("META-INF/dubbo/hessian/serializers", typeDescribers);

typeDescribers.add(buildTypeDescriberWithDeclared(Date.class));
typeDescribers.add(buildTypeDescriberWithDeclared(Time.class));
typeDescribers.add(buildTypeDescriberWithDeclared(Timestamp.class));

return typeDescribers;
}

private void loadFile(String path, List<TypeDescriber> typeDescribers) {
try {
Enumeration<URL> resources = this.getClass().getClassLoader().getResources(path);
while (resources.hasMoreElements()) {
URL url = resources.nextElement();
Properties props = new Properties();
props.load(url.openStream());
for (Object value : props.values()) {
String className = (String) value;
typeDescribers.add(buildTypeDescriberWithDeclared(className));
}
}
} catch (Throwable t) {
// ignore
}
}

private TypeDescriber buildTypeDescriberWithDeclared(Class<?> cl) {
Set<MemberCategory> memberCategories = new HashSet<>();
memberCategories.add(MemberCategory.INVOKE_DECLARED_METHODS);
Expand Down

0 comments on commit 94bd696

Please sign in to comment.