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

fix IllegalAccessException #346

Merged
merged 6 commits into from
Aug 31, 2024
Merged

Conversation

jackie-coming
Copy link
Contributor

修复测试框架没有权限访问报错的问题

@jackie-coming
Copy link
Contributor Author

修复测试框架没有权限访问报错的问题

#342

@jackie-coming
Copy link
Contributor Author

jackie-coming commented Aug 20, 2024

修复测试框架没有权限访问报错的问题

原因:1、本地debug mvn test 可以发现junit4框架调用了System.setOut(),将System.out赋值为
ConsoleOutputCapture$ForwardingPrintStream。 所有调用System.out的地方都会有这个问题。
image

2、ConsoleOutputCapture$ForwardingPrintStream中的ForwardingPrintStream为private,所以执行mvn test时,报
java.lang.IllegalAccessException: Class com.ql.util.express.instruction.op.OperatorMethod can not access a member of class org.apache.maven.surefire.api.report.ConsoleOutputCapture$ForwardingPrintStream with modifiers "public"
image

解决方案:1、调用method.setAccessible(true); 比如com.ql.util.express.instruction.op.OperatorMethod#executeInner
image

2、继承PrintStream,手动调用System.setOut()
image

Copy link
Collaborator

@DQinYuan DQinYuan left a comment

Choose a reason for hiding this comment

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

LGTM

@DQinYuan DQinYuan merged commit 8e3cd01 into alibaba:master Aug 31, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants