8000 static record like methods are no longer supported by bbakerman · Pull Request #3251 · graphql-java/graphql-java · GitHub
[go: up one dir, main page]

Skip to content

static record like methods are no longer supported#3251

Merged
bbakerman merged 4 commits intomasterfrom
static_property_like_methods_should_not_be_used
Jul 9, 2023
Merged

static record like methods are no longer supported#3251
bbakerman merged 4 commits intomasterfrom
static_property_like_methods_should_not_be_used

Conversation

@bbakerman
Copy link
Member
@bbakerman bbakerman commented Jun 15, 2023

This has some challenges. I will discuss them more on the issue #3247

This PR now changes how recordLike() methods are looked up. The use of static recordLike() is no longer supported.

I had intended to NOT make a breaking change but after canvassing this with some others like the team at Spring GraphQL it was suggested that allowing static recordLike() access will present more problems in the future than benefits.

Since this is only 6 months old the scope of the breaking change is smaller than banning static getFoo methods say.

So the breaking change is this - if you have a static recordLike() method - it will no longer be called.

@bbakerman bbakerman added this to the 2023 July milestone Jun 15, 2023
@bbakerman bbakerman added the breaking change requires a new major version to be relased label Jun 25, 2023
try {
MethodFinder methodFinder = (rootClass, methodName) -> findPubliclyAccessibleMethod(cacheKey, rootClass, methodName, dfeInUse);
MethodFinder methodFinder = (rootClass, methodName) -> findPubliclyAccessibleMethod(cacheKey, rootClass, methodName, dfeInUse, false);
return getPropertyViaGetterMethod(object, propertyName, graphQLType, methodFinder, singleArgumentValue);
Copy link
Member Author

Choose a reason for hiding this comment

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

finds non static ones first

// in order to not break things we allow statics to be used. In theory this double code check is not needed
// because you CANT have a `static getFoo()` and a `getFoo()` in the same class hierarchy but to make the code read clearer
// I have repeated the lookup. Since we cache methods, this happens only once and does not slow us down
MethodFinder methodFinder = (rootClass, methodName) -> findPubliclyAccessibleMethod(cacheKey, rootClass, methodName, dfeInUse, true);
Copy link
Member Author

Choose a reason for hiding this comment

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

finds static getters next

*/
private Method findRecordMethod(CacheKey cacheKey, Class<?> rootClass, String methodName) throws NoSuchMethodException {
return findPubliclyAccessibleMethod(cacheKey, rootClass, methodName, false);
return findPubliclyAccessibleMethod(cacheKey, rootClass, methodName, false, false);
Copy link
Member Author

Choose a reason for hiding this comment

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

NEVER finds static recordLike() methods now

@Override
String getSomething() {
return "bar";
return "bar"
Copy link
Member Author

Choose a reason for hiding this comment

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

yellow tagged IDEA code cleanup

@bbakerman bbakerman changed the title issue 3247 - reproduction of reported case static record like methods are no longer supported Jun 27, 2023
@bbakerman bbakerman added 9ED5 this pull request to the merge queue Jul 9, 2023
Merged via the queue into master with commit c1395c8 Jul 9, 2023
dondonz added a commit that referenced this pull request Apr 2, 2024
…-for-special-release

Cherry pick PR #3251: Remove static record-like method lookup - for special 20.9 Atlassian release
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change requires a new major version to be relased

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0