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

fixed pojoutils string class issue #14102

Open
wants to merge 7 commits into
base: 3.2
Choose a base branch
from

Conversation

zcbbpo
Copy link
Contributor

@zcbbpo zcbbpo commented Apr 19, 2024

Hi

Environment

  • Dubbo version: 3.2.0
  • Operating System version: mac os 12.2
  • Java version: 21

when i use telnet to invoke , it will throw exception
dubbo>invoke com.xxx.api.PService.check({"value": 1, "class": "java.lang.Long"}, {"value": 1, "class": "java.lang.Long"}, {"value": "abc", "class": "java.lang.String"}, {"value": "c", "class": "java.lang.String"})
Its response:
image

i have add this code for fixed issue: org.apache.dubbo.common.utils.PojoUtils#realize0
image

this is test case

image

Brief changelog

Verifying this change

Checklist

  • Make sure there is a GitHub_issue field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
  • Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in dubbo samples project.
  • Add some description to dubbo-website project if you are requesting to add a feature.
  • GitHub Actions works fine on your own branch.
  • If this contribution is large, please follow the Software Donation Guide.

@AlbumenJ
Copy link
Member

AlbumenJ commented May 8, 2024

image
Please fix the code style

@AlbumenJ
Copy link
Member

AlbumenJ commented May 8, 2024

image

@zcbbpo
Copy link
Contributor Author

zcbbpo commented May 8, 2024

image
is use jdk21 to run unit test?
it's should requred to add jvm args "--add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED"? please help to check

@AlbumenJ
Copy link
Member

AlbumenJ commented May 8, 2024

image is use jdk21 to run unit test? it's should requred to add jvm args "--add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.reflect.generics.reflectiveObjects=ALL-UNNAMED"? please help to check

As design, Dubbo itself should not require any --add-opens configuration

@zcbbpo
Copy link
Contributor Author

zcbbpo commented May 8, 2024

in this method: org.apache.dubbo.common.utils.PojoUtils#getField
image
when the acls is jdk class , we cannot modify field accessible. could we can add this code to ignore jdk classes?

@zcbbpo
Copy link
Contributor Author

zcbbpo commented May 8, 2024

image
add check it's if jdk classes

Copy link

sonarcloud bot commented May 8, 2024

Copy link

sonarcloud bot commented Jun 24, 2024

@@ -774,7 +778,8 @@ private static Field getField(Class<?> cls, String fieldName) {
for (Class<?> acls = cls; acls != null; acls = acls.getSuperclass()) {
try {
result = acls.getDeclaredField(fieldName);
if (!Modifier.isPublic(result.getModifiers())) {
// the field is not public and it not jdk class, we will setAccessible to true
if (!Modifier.isPublic(result.getModifiers()) && acls.getClassLoader() != null) {
Copy link
Member

Choose a reason for hiding this comment

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

For JDK internal classes, even if they don't fail here, they will eventually fail.

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.

3 participants