Skip to content

Commit 068ccac

Browse files
authored
Merge pull request quarkusio#53635 from FroMage/json-reflection-skip-private-methods
REST + JSON: ignore private methods
2 parents 68c263c + 7fcbae2 commit 068ccac

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

extensions/resteasy-classic/resteasy-common/spi/src/main/java/io/quarkus/resteasy/common/spi/ResteasyDotNames.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.quarkus.resteasy.common.spi;
22

3+
import java.lang.reflect.Modifier;
34
import java.util.HashSet;
45
import java.util.List;
56
import java.util.Set;
@@ -96,7 +97,10 @@ private static class IgnoreMethodForReflectionPredicate implements Predicate<Met
9697

9798
@Override
9899
public boolean test(MethodInfo methodInfo) {
99-
return methodInfo.hasAnnotation(JSON_IGNORE)
100+
// Non-public methods are not required by JSON serialisation, and may lead to leaking of implementation
101+
// types that we should not register.
102+
return !Modifier.isPublic(methodInfo.flags())
103+
|| methodInfo.hasAnnotation(JSON_IGNORE)
100104
|| methodInfo.hasAnnotation(JSONB_TRANSIENT)
101105
|| methodInfo.hasAnnotation(XML_TRANSIENT);
102106
}

extensions/resteasy-reactive/rest-common/deployment/src/main/java/io/quarkus/resteasy/reactive/common/deployment/QuarkusResteasyReactiveDotNames.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.quarkus.resteasy.reactive.common.deployment;
22

3+
import java.lang.reflect.Modifier;
34
import java.util.function.Predicate;
45

56
import org.jboss.jandex.DotName;
@@ -70,7 +71,10 @@ private static class IgnoreMethodForReflectionPredicate implements Predicate<Met
7071

7172
@Override
7273
public boolean test(MethodInfo methodInfo) {
73-
return methodInfo.hasAnnotation(JSON_IGNORE)
74+
// Non-public methods are not required by JSON serialisation, and may lead to leaking of implementation
75+
// types that we should not register.
76+
return !Modifier.isPublic(methodInfo.flags())
77+
|| methodInfo.hasAnnotation(JSON_IGNORE)
7478
|| methodInfo.hasAnnotation(JSONB_TRANSIENT);
7579
}
7680
}

0 commit comments

Comments
 (0)