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

Refactor and add ut for ClassUtils #4887

Closed
wants to merge 2 commits into from

Conversation

bowenliang123
Copy link
Contributor

@bowenliang123 bowenliang123 commented May 25, 2023

Why are the changes needed?

  • add unit tests for ClassUtils
  • refactor ClassUtils.createInstance method with DynConstructors
  • move classIsLoadable method to ReflectUtils.isClassLoadable, refeactor to use DynClasses

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before make a pull request

@bowenliang123 bowenliang123 marked this pull request as ready for review May 25, 2023 14:35
@codecov-commenter
Copy link

codecov-commenter commented May 26, 2023

Codecov Report

Merging #4887 (c39f9a0) into master (07e590a) will not change coverage.
The diff coverage is 0.00%.

@@          Coverage Diff           @@
##           master   #4887   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         557     557           
  Lines       30705   30694   -11     
  Branches     3997    3993    -4     
======================================
+ Misses      30705   30694   -11     
Impacted Files Coverage Δ
...src/main/scala/org/apache/spark/ui/EngineTab.scala 0.00% <0.00%> (ø)
...mon/src/main/scala/org/apache/kyuubi/Logging.scala 0.00% <0.00%> (ø)
...main/scala/org/apache/kyuubi/util/ClassUtils.scala 0.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@bowenliang123
Copy link
Contributor Author

bowenliang123 commented May 26, 2023

Can I move the isClassLoadable method from kyuubi-util-scala's ReflectUtils to kyuubi-util's DynClasses as a static method for Java as well ? @pan3793

@pan3793
Copy link
Member

pan3793 commented May 27, 2023

Can I move the isClassLoadable method from kyuubi-util-scala's ReflectUtils to kyuubi-util's DynClasses as a static method for Java as well ? @pan3793

It's fine if other places can benefit from it, but since Java does not support the default value, it should be broken into multi-methods

@bowenliang123
Copy link
Contributor Author

Can I move the isClassLoadable method from kyuubi-util-scala's ReflectUtils to kyuubi-util's DynClasses as a static method for Java as well ? @pan3793

It's fine if other places can benefit from it, but since Java does not support the default value, it should be broken into multi-methods

OK, let's leave it in Scala module for now. As for Java, it's handy to use workaround DynClasses.builder().loader(cl).impl(className).orNull().build() != null for checking the class loadable.

@bowenliang123 bowenliang123 self-assigned this May 29, 2023
@bowenliang123 bowenliang123 added this to the v1.8.0 milestone May 29, 2023
@bowenliang123 bowenliang123 deleted the classutil branch May 29, 2023 08:56
@bowenliang123
Copy link
Contributor Author

Thanks, merged to master.

huangzhir pushed a commit to huangzhir/kyuubi that referenced this pull request May 30, 2023
### _Why are the changes needed?_

- add unit tests for `ClassUtils`
- refactor `ClassUtils.createInstance` method with DynConstructors
- move `classIsLoadable` method to `ReflectUtils.isClassLoadable`, refeactor to use DynClasses

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request

Closes apache#4887 from bowenliang123/classutil.

Closes apache#4887

c39f9a0 [liangbowen] simplify ut
633e21d [liangbowen] Refactor and add ut for ClassUtils

Authored-by: liangbowen <liangbowen@gf.com.cn>
Signed-off-by: liangbowen <liangbowen@gf.com.cn>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants