Skip to content

Commit

Permalink
bugfix: Use Proxy.getInvocationHandler instead of reflection (#5201)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbumenJ authored Dec 26, 2022
1 parent 083c718 commit 1bad3b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 2 additions & 0 deletions changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Add changes here for all PR submitted to the develop branch.
### bugfix:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] fix xxx
- [[#5194](https://github.com/seata/seata/pull/5194)] fix wrong keyword order for oracle when creating a table
- [[#5021](https://github.com/seata/seata/pull/5201)] Fix JDK Reflection for Spring origin proxy failed in JDK17

### optimize:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] optimize xxx
Expand All @@ -20,5 +21,6 @@ Thanks to these contributors for their code commits. Please report an unintended
<!-- Please make sure your Github ID is in the list below -->
- [slievrly](https://github.com/slievrly)
- [xssdpgy](https://github.com/xssdpgy)
- [albumenj](https://github.com/albumenj)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
2 changes: 2 additions & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
### bugfix:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] 修复 xxx
- [[#5194](https://github.com/seata/seata/pull/5194)] 修复使用Oracle作为服务端DB存储时的建表失败问题
- [[#5021](https://github.com/seata/seata/pull/5201)] 修复 JDK17 下获取 Spring 原始代理对象失败的问题

### optimize:
- [[#xxx](https://github.com/seata/seata/pull/xxx)] 优化 xxx
Expand All @@ -20,5 +21,6 @@
<!-- 请确保您的 GitHub ID 在以下列表中 -->
- [slievrly](https://github.com/slievrly)
- [xssdpgy](https://github.com/xssdpgy)
- [albumenj](https://github.com/albumenj)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
10 changes: 5 additions & 5 deletions spring/src/main/java/io/seata/spring/util/SpringProxyUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@ private static Class<?>[] getInterfacesByAdvised(AdvisedSupport advised) {
* @throws Exception the exception
*/
public static AdvisedSupport getAdvisedSupport(Object proxy) throws Exception {
Field h;
Object dynamicAdvisedInterceptor;
if (AopUtils.isJdkDynamicProxy(proxy)) {
h = proxy.getClass().getSuperclass().getDeclaredField("h");
dynamicAdvisedInterceptor = Proxy.getInvocationHandler(proxy);
} else {
h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0");
h.setAccessible(true);
dynamicAdvisedInterceptor = h.get(proxy);
}
h.setAccessible(true);
Object dynamicAdvisedInterceptor = h.get(proxy);
Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised");
advised.setAccessible(true);
return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor);
Expand Down

0 comments on commit 1bad3b8

Please sign in to comment.