Skip to content

Commit

Permalink
[huaweicloud#925]upgrade spring cloud version (huaweicloud#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 authored Nov 17, 2022
1 parent 7d59718 commit 4763c35
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 42 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<!-- This version should match spring-cloud-dependencies 'spring-cloud-build.version' -->
<version>3.1.3</version>
<version>3.1.5</version>
</parent>

<groupId>com.huaweicloud</groupId>
Expand All @@ -37,9 +37,9 @@
<java.version>1.8</java.version>
<!-- spring-cloud-dependencies do not import spring-boot-dependencies, spring-boot-dependencies
import spring-framework-bom. No need configure spring version. -->
<spring.version>5.3.18</spring.version>
<spring-cloud.version>2021.0.3</spring-cloud.version>
<spring-boot.version>2.6.7</spring-boot.version>
<spring.version>5.3.23</spring.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-boot.version>2.6.13</spring-boot.version>
<servicecomb.version>2.7.10</servicecomb.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

package org.springframework.cloud.openfeign.support;

import static org.springframework.cloud.openfeign.support.FeignUtils.getHttpHeaders;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static org.springframework.http.MediaType.MULTIPART_MIXED;
import static org.springframework.http.MediaType.MULTIPART_RELATED;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
Expand All @@ -24,18 +30,13 @@
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import feign.RequestTemplate;
import feign.codec.EncodeException;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import org.springframework.beans.factory.ObjectFactory;
import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
Expand All @@ -50,15 +51,14 @@
import org.springframework.http.converter.protobuf.ProtobufHttpMessageConverter;
import org.springframework.web.multipart.MultipartFile;

import static org.springframework.cloud.openfeign.support.FeignUtils.getHeaders;
import static org.springframework.cloud.openfeign.support.FeignUtils.getHttpHeaders;
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED;
import static org.springframework.http.MediaType.MULTIPART_FORM_DATA;
import static org.springframework.http.MediaType.MULTIPART_MIXED;
import static org.springframework.http.MediaType.MULTIPART_RELATED;

import com.huaweicloud.hessian.HessianHttpMessageConverter;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import feign.RequestTemplate;
import feign.codec.EncodeException;
import feign.codec.Encoder;
import feign.form.spring.SpringFormEncoder;

/**
* @author Spencer Gibb
* @author Scien Jus
Expand Down Expand Up @@ -87,29 +87,6 @@ public class ExtendedSpringEncoder implements Encoder {

private final ObjectProvider<HttpMessageConverterCustomizer> customizers;

public ExtendedSpringEncoder(ObjectFactory<HttpMessageConverters> messageConverters) {
this(new SpringFormEncoder(), messageConverters);
}

/**
* @deprecated in favour of
* {@link SpringEncoder#SpringEncoder(SpringFormEncoder, ObjectFactory, FeignEncoderProperties, ObjectProvider)}
*/
@Deprecated
public ExtendedSpringEncoder(SpringFormEncoder springFormEncoder, ObjectFactory<HttpMessageConverters> messageConverters) {
this(springFormEncoder, messageConverters, new FeignEncoderProperties());
}

/**
* @deprecated in favour of
* {@link SpringEncoder#SpringEncoder(SpringFormEncoder, ObjectFactory, FeignEncoderProperties, ObjectProvider)}
*/
@Deprecated
public ExtendedSpringEncoder(SpringFormEncoder springFormEncoder, ObjectFactory<HttpMessageConverters> messageConverters,
FeignEncoderProperties encoderProperties) {
this(springFormEncoder, messageConverters, encoderProperties, new EmptyObjectProvider<>());
}

public ExtendedSpringEncoder(SpringFormEncoder springFormEncoder, ObjectFactory<HttpMessageConverters> messageConverters,
FeignEncoderProperties encoderProperties, ObjectProvider<HttpMessageConverterCustomizer> customizers) {
this.springFormEncoder = springFormEncoder;
Expand Down Expand Up @@ -167,7 +144,7 @@ private void encodeWithMessageConverter(Object requestBody, Type bodyType, Reque
request.headers(null);
// converters can modify headers, so update the request
// with the modified headers
request.headers(getHeaders(outputMessage.getHeaders()));
request.headers(new LinkedHashMap<>(outputMessage.getHeaders()));

// do not use charset for binary data and protobuf
Charset charset;
Expand Down Expand Up @@ -256,7 +233,7 @@ private boolean isFormUrlEncoded(MediaType requestContentType) {
return Objects.equals(APPLICATION_FORM_URLENCODED, requestContentType);
}

private boolean binaryContentType(FeignOutputMessage outputMessage) {
protected boolean binaryContentType(FeignOutputMessage outputMessage) {
MediaType contentType = outputMessage.getHeaders().getContentType();
return contentType == null || HessianHttpMessageConverter.HESSIAN_MEDIA_TYPE.includes(contentType) || Stream
.of(MediaType.APPLICATION_CBOR, MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_PDF,
Expand Down

0 comments on commit 4763c35

Please sign in to comment.