Skip to content
Open
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
2 changes: 2 additions & 0 deletions eclipse/checkstyle-suppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
<suppressions>
<suppress files="[\\/]spring-cloud-alibaba-examples[\\/]" checks="HideUtilityClassConstructorCheck" />
<suppress files="[\\/]spring-cloud-alibaba-tests[\\/]" checks="HideUtilityClassConstructorCheck" />
<suppress files=".java" checks="AvoidStarImport" />
<suppress files=".java" checks="RegexpSinglelineJava" />
<suppress files=".*" checks="LineLength" />
</suppressions>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-build</artifactId>
<version>4.1.3</version>
<version>4.3.0</version>
<relativePath/>
</parent>

Expand Down Expand Up @@ -80,13 +80,13 @@

<properties>
<!-- Project revision -->
<revision>2023.0.3.3</revision>
<revision>2025.0.0.0</revision>

<!-- Spring Cloud -->
<spring.cloud.version>2023.0.3</spring.cloud.version>
<spring.cloud.version>2025.0.0</spring.cloud.version>

<!-- Spring Boot -->
<spring-boot.version>3.2.9</spring-boot.version>
<spring-boot.version>3.5.0</spring-boot.version>

<!-- Maven Plugin Versions -->
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
Expand Down
15 changes: 8 additions & 7 deletions spring-cloud-alibaba-dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies-parent</artifactId>
<version>4.1.0</version>
<version>4.3.0</version>
<relativePath/>
</parent>

Expand All @@ -18,15 +18,16 @@
<description>Spring Cloud Alibaba Dependencies</description>

<properties>
<revision>2023.0.3.3</revision>
<revision>2025.0.0.0</revision>
<sentinel.version>1.8.8</sentinel.version>
<nacos.client.version>2.4.2</nacos.client.version>
<seata.version>2.1.0</seata.version>
<nacos.client.version>3.0.1</nacos.client.version>
<seata.version>2.3.0</seata.version>
<!-- Apache RocketMQ -->
<rocketmq.version>5.3.1</rocketmq.version>
<rocketmq.version>5.3.3</rocketmq.version>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, 在升级时有运行项目中的 example 例子吗?确保 example 正常运行且符合预期很有必要

<rocketmq.acl.version>5.3.2</rocketmq.acl.version>

<!-- scheduling -->
<shedlock.version>4.23.0</shedlock.version>
<shedlock.version>6.9.0</shedlock.version>
<schedulerx.worker.version>1.11.4</schedulerx.worker.version>

<!-- Maven Plugin Versions -->
Expand Down Expand Up @@ -167,7 +168,7 @@
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-acl</artifactId>
<version>${rocketmq.version}</version>
<version>${rocketmq.acl.version}</version>
</dependency>

<!-- Alibaba scheduling -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import com.alibaba.cloud.commons.lang.StringUtils;
import com.alibaba.cloud.nacos.NacosDiscoveryProperties;
import com.alibaba.cloud.nacos.util.InetIPv6Utils;
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
import jakarta.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -149,7 +148,7 @@ private Response<ServiceInstance> getInstanceResponse(Request<?> request,
.get("nacos.cluster");
return StringUtils.equals(cluster, clusterName);
}).collect(Collectors.toList());
if (!CollectionUtils.isEmpty(sameClusterInstances)) {
if (!sameClusterInstances.isEmpty()) {
instancesToChoose = sameClusterInstances;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

import java.util.Collections;
import java.util.List;
import java.util.concurrent.Future;

import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.listener.EventListener;
import com.alibaba.nacos.api.naming.listener.FuzzyWatchEventWatcher;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
Expand Down Expand Up @@ -370,4 +372,35 @@ public void unsubscribe(String s, NamingSelector namingSelector, EventListener e
public void unsubscribe(String s, String s1, NamingSelector namingSelector, EventListener eventListener) throws NacosException {

}

@Override
public void fuzzyWatch(String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里文件的作用是什么?似乎它时一个空的 Mock 文件?


}

@Override
public void fuzzyWatch(String serviceNamePattern, String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {

}

@Override
public Future<ListView<String>> fuzzyWatchWithServiceKeys(String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {
return null;
}

@Override
public Future<ListView<String>> fuzzyWatchWithServiceKeys(String serviceNamePattern, String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {
return null;
}

@Override
public void cancelFuzzyWatch(String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {

}

@Override
public void cancelFuzzyWatch(String serviceNamePattern, String groupNamePattern, FuzzyWatchEventWatcher listener) throws NacosException {

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Copyright 2013-2023 the original author or authors.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

版权年份应该是 2013-2025

*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.alibaba.cloud.sentinel.rest;

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

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.util.Assert;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

多了一个空行,下文也是


public class BaseHttpInputMessage implements HttpInputMessage {

private final HttpHeaders headers = new HttpHeaders();
private final InputStream body;


/**
* Create a {@code MockHttpInputMessage} with the supplied body.
*/
public BaseHttpInputMessage(byte[] body) {
Assert.notNull(body, "Byte array must not be null");
this.body = new ByteArrayInputStream(body);
}

/**
* Create a {@code MockHttpInputMessage} with the supplied body.
*/
public BaseHttpInputMessage(InputStream body) {
Assert.notNull(body, "InputStream must not be null");
this.body = body;
}


@Override
public HttpHeaders getHeaders() {
return this.headers;
}

@Override
public InputStream getBody() throws IOException {
return this.body;
}

}

Original file line number Diff line number Diff line change
Expand Up @@ -16,66 +16,95 @@

package com.alibaba.cloud.sentinel.rest;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.cloud.sentinel.annotation.SentinelRestTemplate;
import com.alibaba.cloud.sentinel.custom.SentinelProtectInterceptor;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.client.AbstractClientHttpResponse;
import org.springframework.http.HttpStatusCode;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.Assert;

/**
* Using by {@link SentinelRestTemplate} and {@link SentinelProtectInterceptor}.
*
* @author <a href="mailto:fangjian0423@gmail.com">Jim</a>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尽量不要删除这里的作者签名

*/
public class SentinelClientHttpResponse extends AbstractClientHttpResponse {

private String blockResponse = "RestTemplate request block by sentinel";
public class SentinelClientHttpResponse extends BaseHttpInputMessage implements ClientHttpResponse {

private final HttpStatusCode statusCode;

private static final String BLOCK_RESPONSE = "RestTemplate request block by sentinel";
//private String blockResponse = BLOCK_RESPONSE;

/**
* Create a {@code SentinelMyClientHttpResponse} with an empty response body and
* HTTP status code {@link HttpStatus#OK OK}.
*
* @since 6.0.3
*/
public SentinelClientHttpResponse() {
this(BLOCK_RESPONSE.getBytes(), HttpStatus.OK);
}

public SentinelClientHttpResponse(String blockResponse) {
this.blockResponse = blockResponse;
this(blockResponse.getBytes(), HttpStatus.OK);
}

@Override
public int getRawStatusCode() throws IOException {
return HttpStatus.OK.value();
/**
* Create a {@code SentinelMyClientHttpResponse} with response body as a byte array
* and the supplied HTTP status code.
*/
public SentinelClientHttpResponse(byte[] body, HttpStatusCode statusCode) {
super(body);
Assert.notNull(statusCode, "HttpStatusCode must not be null");
this.statusCode = statusCode;
}

@Override
public String getStatusText() throws IOException {
return blockResponse;
/**
* Create a {@code SentinelMyClientHttpResponse} with response body as a byte array
* and a custom HTTP status code.
*
* @since 5.3.17
*/
public SentinelClientHttpResponse(byte[] body, int statusCode) {
this(body, HttpStatusCode.valueOf(statusCode));
}

/**
* Create a {@code SentinelMyClientHttpResponse} with response body as {@link InputStream}
* and the supplied HTTP status code.
*/
public SentinelClientHttpResponse(InputStream body, HttpStatusCode statusCode) {
super(body);
Assert.notNull(statusCode, "HttpStatusCode must not be null");
this.statusCode = statusCode;
}

/**
* Create a {@code SentinelMyClientHttpResponse} with response body as {@link InputStream}
* and a custom HTTP status code.
*
* @since 5.3.17
*/
public SentinelClientHttpResponse(InputStream body, int statusCode) {
this(body, HttpStatusCode.valueOf(statusCode));
}


@Override
public void close() {
// nothing do
public HttpStatusCode getStatusCode() {
return this.statusCode;
}

@Override
public InputStream getBody() throws IOException {
return new ByteArrayInputStream(blockResponse.getBytes());
public String getStatusText() {
return (this.statusCode instanceof HttpStatus status ? status.getReasonPhrase() : "");
}

@Override
public HttpHeaders getHeaders() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi, 我看到这里是移到了 BaseHttpInputMessage 类中吗?

Map<String, List<String>> headers = new HashMap<>();
headers.put(HttpHeaders.CONTENT_TYPE,
Arrays.asList(MediaType.APPLICATION_JSON_VALUE));
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.putAll(headers);
return httpHeaders;
public void close() {
try {
getBody().close();
}
catch (IOException ex) {
// ignore
}
}

}
Loading