-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix findPubliclyAccessibleMethod to search interfaces for accessible methods #4287
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d37c600
Fix findPubliclyAccessibleMethod to search interfaces for accessible …
claude ff9c80d
Merge branch 'master' into claude/fix-graphql-java-4278-v6Z3y
andimarek a3eac73
Add tests for recursive interface method resolution
andimarek 3805adf
Merge branch 'master' into claude/fix-graphql-java-4278-v6Z3y
andimarek 50f05ba
Merge branch 'master' into claude/fix-graphql-java-4278-v6Z3y
andimarek 48d75c0
Merge branch 'master' into claude/fix-graphql-java-4278-v6Z3y
andimarek ec01d15
Merge branch 'master' into claude/fix-graphql-java-4278-v6Z3y
andimarek e718c23
Add tests for findMethodOnPublicInterfaces coverage gaps
andimarek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
src/test/groovy/graphql/schema/somepackage/InterfaceInheritanceHolder.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| package graphql.schema.somepackage; | ||
|
|
||
| import graphql.schema.DataFetchingEnvironment; | ||
|
|
||
| /** | ||
| * Test fixtures for interface-extends-interface method resolution. | ||
| * <p> | ||
| * Tests the recursive interface search in findMethodOnPublicInterfaces: | ||
| * a package-private class implements a package-private interface that extends | ||
| * a public interface. The method is only declared on the public grandparent, | ||
| * so the algorithm must recursively traverse through the package-private | ||
| * interface to find it. | ||
| * <p> | ||
| * Linear chain: | ||
| * <pre> | ||
| * PublicBaseInterface (public) — defines getBaseValue() | ||
| * | | ||
| * PackagePrivateMiddleInterface — extends PublicBaseInterface (adds nothing new) | ||
| * | | ||
| * PackagePrivateChainImpl (package-private) — implements PackagePrivateMiddleInterface | ||
| * </pre> | ||
| * <p> | ||
| * Diamond pattern: | ||
| * <pre> | ||
| * PublicBaseInterface (public) — defines getBaseValue() | ||
| * / \ | ||
| * PackagePrivateBranchA PackagePrivateBranchB — each adds own method | ||
| * \ / | ||
| * DiamondImpl (package-private) | ||
| * </pre> | ||
| */ | ||
| public class InterfaceInheritanceHolder { | ||
|
|
||
| // --- Linear interface chain --- | ||
|
|
||
| public interface PublicBaseInterface { | ||
| String getBaseValue(); | ||
| } | ||
|
|
||
| // Package-private interface extending a public interface — adds no new methods | ||
| interface PackagePrivateMiddleInterface extends PublicBaseInterface { | ||
| } | ||
|
|
||
| // Package-private class: only implements the package-private interface. | ||
| // getBaseValue() is declared on PublicBaseInterface — the recursive search | ||
| // must traverse PackagePrivateMiddleInterface -> PublicBaseInterface to find it. | ||
| static class PackagePrivateChainImpl implements PackagePrivateMiddleInterface { | ||
| @Override | ||
| public String getBaseValue() { | ||
| return "baseValue"; | ||
| } | ||
| } | ||
|
|
||
| // --- Diamond pattern --- | ||
|
|
||
| // Two package-private interfaces both extending PublicBaseInterface | ||
| interface PackagePrivateBranchA extends PublicBaseInterface { | ||
| String getBranchAValue(); | ||
| } | ||
|
|
||
| interface PackagePrivateBranchB extends PublicBaseInterface { | ||
| String getBranchBValue(); | ||
| } | ||
|
|
||
| // Package-private class implementing both branches (diamond). | ||
| // getBaseValue() is only on PublicBaseInterface — must be found through either branch. | ||
| static class DiamondImpl implements PackagePrivateBranchA, PackagePrivateBranchB { | ||
| @Override | ||
| public String getBaseValue() { | ||
| return "diamondBaseValue"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getBranchAValue() { | ||
| return "branchAValue"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getBranchBValue() { | ||
| return "branchBValue"; | ||
| } | ||
| } | ||
|
|
||
| // --- DFE interface: public interface with a method accepting DataFetchingEnvironment --- | ||
|
|
||
| public interface PublicDfeInterface { | ||
| String getDfeValue(DataFetchingEnvironment dfe); | ||
| } | ||
|
|
||
| // Package-private class implementing the public DFE interface. | ||
| // Exercises the dfeInUse path in findMethodOnPublicInterfaces. | ||
| static class PackagePrivateDfeImpl implements PublicDfeInterface { | ||
| @Override | ||
| public String getDfeValue(DataFetchingEnvironment dfe) { | ||
| return "dfeValue"; | ||
| } | ||
| } | ||
|
|
||
| // --- Interface with multiple methods: one exists, one doesn't --- | ||
| // Used to exercise the NoSuchMethodException catch path in findMethodOnPublicInterfaces. | ||
|
|
||
| public interface PublicInterfaceWithoutTarget { | ||
| String getUnrelatedValue(); | ||
| } | ||
|
|
||
| // Package-private class implementing an interface that does NOT have the fetched property. | ||
| // Also implements PublicBaseInterface which DOES have it. | ||
| // The search hits NoSuchMethodException on PublicInterfaceWithoutTarget, then finds it on PublicBaseInterface. | ||
| static class PackagePrivateMultiInterfaceImpl implements PublicInterfaceWithoutTarget, PublicBaseInterface { | ||
| @Override | ||
| public String getUnrelatedValue() { | ||
| return "unrelated"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getBaseValue() { | ||
| return "foundViaSecondInterface"; | ||
| } | ||
| } | ||
|
|
||
| // --- Factory methods (public entry points for tests) --- | ||
|
|
||
| public static Object createChainImpl() { | ||
| return new PackagePrivateChainImpl(); | ||
| } | ||
|
|
||
| public static Object createDiamondImpl() { | ||
| return new DiamondImpl(); | ||
| } | ||
|
|
||
| public static Object createDfeImpl() { | ||
| return new PackagePrivateDfeImpl(); | ||
| } | ||
|
|
||
| public static Object createMultiInterfaceImpl() { | ||
| return new PackagePrivateMultiInterfaceImpl(); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You allowing interfaces implementing interfaces - fair enough - but there is not tests for that
I think you need to create the complicated structure that tests this