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

自定义的Resttemplate,无法被SentialResttemplate注解强化 #3329

Closed
linzhiqiang0514 opened this issue May 29, 2023 · 1 comment · Fixed by #3339
Closed

自定义的Resttemplate,无法被SentialResttemplate注解强化 #3329

linzhiqiang0514 opened this issue May 29, 2023 · 1 comment · Fixed by #3339
Assignees
Labels
area/sentinel spring cloud alibaba sentinel kind/bug Mark as bug

Comments

@linzhiqiang0514
Copy link

我们鼓励使用英文,如果不能直接使用,可以使用翻译软件,您仍旧可以保留中文原文。另外请按照如下要求提交相关信息节省社区维护同学的理解成本,否则该讨论极有可能直接被忽视或关闭。
We recommend using English. If you are non-native English speaker, you can use the translation software. We recommend using English. If you are non-native English speaker, you can use the translation software. In addition, please submit relevant information according to the following requirements to save the understanding cost of community maintenances, otherwise the discussion is very likely to be ignored or closed directly.

Which Component
Sentinel

Describe the bug
A clear and concise description of what the bug is.
当我使用自定义的RestTemplate时,com.alibaba.cloud.sentinel.custom.SentinelBeanPostProcessor#postProcessMergedBeanDefinition
判断逻辑错误,无法判断自定义的RestTemplate
if (beanName == null || beanType != RestTemplate.class) {

Simplest demo
The URL of the simplest demo to reproduce the problem.

public class CustomRestTemplate extends RestTemplate {
}

@bean("internalRestTemplate")
@LoadBalanced
@primary
@SentinelRestTemplate(fallbackClass = ExceptionUtil.class, fallback = "handleFallback",
blockHandler = "handleBlock",blockHandlerClass = ExceptionUtil.class)
public RestTemplate internalRestTemplate(
@Autowired @qualifier("restHttpClient") CloseableHttpClient httpClient,
PlatformHttpRequestInterceptor platformHttpRequestInterceptor,
PlatformResponseErrorHandler platformResponseErrorHandler) {
logger.info("SentinelPlatformRestTemplate开始!");

    CustomRestTemplate restTemplate = new CustomRestTemplate(
        new HttpComponentsClientHttpRequestFactory(httpClient));
    logger.info("SentinelPlatformRestTemplate创建成功!ClientInfo:{}", httpClient);
    return restTemplate;
}

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.
e.g. MacOS 、Java8 、 Version 0.2.1.RELEASE
version: 2022.0.0.0-RC2

ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 8, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 8, 2023
@ruansheng8 ruansheng8 added kind/bug Mark as bug area/sentinel spring cloud alibaba sentinel labels Jun 8, 2023
@ruansheng8
Copy link
Collaborator

I willl fix it

@ruansheng8 ruansheng8 self-assigned this Jun 8, 2023
steverao pushed a commit that referenced this issue Jun 8, 2023
* Fix: SentinelRestTemplate support custom RestTemplate (#3329)

* Add fix comment (#3329)
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 9, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 9, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 9, 2023
ruansheng8 added a commit to ruansheng8/spring-cloud-alibaba that referenced this issue Jun 9, 2023
steverao pushed a commit that referenced this issue Jun 11, 2023
#3345)

* Fix: SentinelRestTemplate support custom RestTemplate (#3329)

* Add fix comment (#3329)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/sentinel spring cloud alibaba sentinel kind/bug Mark as bug
Projects
None yet
2 participants