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

Spring upgrade to 3.3.6 #8325

Merged
merged 28 commits into from
Dec 10, 2024
Merged

Spring upgrade to 3.3.6 #8325

merged 28 commits into from
Dec 10, 2024

Conversation

DavidMcClatchey
Copy link
Collaborator

BACKEND PULL REQUEST

Related Issue

Changes Proposed

  • Updates all relevant dependencies in the build.gradle and gradle.lockfile in order to update overall to Spring 3.3.6
  • Adds new getter for the isDeleted field in EternalAuditedEntity that starts with get in order for GraphQL introspection from the Spring GraphQL dependency to succeed
  • Updates deprecated GraphQL methods and method to retrieve HTTP status code

Additional Information

  • During this upgrade, Spring 3.4 came out, so we should upgrade to that in the future

Testing

  • Build and run locally
  • Deployed on dev3

Checklist for Primary Reviewer

  • Any large-scale changes have been deployed to test, dev, or pentest and smoke tested
  • Changes comply with the SimpleReport Style Guide
  • Changes with security implications have been approved by a security engineer (changes to authentication, encryption, handling of PII, etc.)
  • Any dependencies introduced have been vetted and discussed

@DavidMcClatchey DavidMcClatchey marked this pull request as ready for review December 3, 2024 17:23

@Slf4j
class DateTimeScalarCoercion implements Coercing<Date, Object> {
public class DateTimeScalarCoercion implements Coercing<Date, Object> {
Copy link
Collaborator Author

@DavidMcClatchey DavidMcClatchey Dec 3, 2024

Choose a reason for hiding this comment

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

Class and methods were made public for unit testing, similar to FlexibleDateCoercion.java, which also implements Coercing.

@NotNull Object dataFetcherResult,
@NotNull GraphQLContext graphQLContext,
@NotNull Locale locale)
throws CoercingSerializeException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

Copy link
Collaborator

@emyl3 emyl3 Dec 4, 2024

Choose a reason for hiding this comment

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

Question for my own understanding... (I have never upgraded Spring before 😅) How did you know this method should now look like this? Was it trial and error or is there some resource you are taking this from? 🤔 This question applies in general for the overridden methods that changed 👀

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

IIRC, I was mainly alerted through Intellij after updating the dependency related to the change. e.g. after updating the dependency but before updating the code, it looked like this:
Screenshot 2024-12-04 at 1 46 24 PM
So then after seeing that, I'd look into the Coercing interface for what should replace it. Luckily there are usually replacements for deprecated methods and they're not just wiped out entirely.

Another Intellij trick is to right click on the root folder, then Analyze -> Run Inspection by Name and type in "deprecated" and then click on the one for Java:

Screenshot 2024-12-04 at 2 00 39 PM

Then it'll show you anything that's deprecated or that altogether doesn't work anymore 🧐

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you for the detailed explanation and going over this in eng sync as well 🙌

if (((String) input).length() == 0) {
public Date parseValue(
@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale)
throws CoercingParseValueException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

@NotNull CoercedVariables coercedVariables,
@NotNull GraphQLContext graphQLContext,
@NotNull Locale locale)
throws CoercingParseLiteralException {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

public Object serialize(
@NotNull Object dataFetcherResult,
@NotNull GraphQLContext graphQLContext,
@NotNull Locale locale) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

@@ -45,7 +53,8 @@ public Object serialize(Object dataFetcherResult) {
}

@Override
public Object parseValue(Object input) {
public Object parseValue(
@NotNull Object input, @NotNull GraphQLContext graphQLContext, @NotNull Locale locale) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

@NotNull Value<?> input,
@NotNull CoercedVariables coercedVariables,
@NotNull GraphQLContext graphQLContext,
@NotNull Locale locale) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Previous overridden method signature was deprecated in favor of this.

@@ -21,6 +21,10 @@ public boolean isDeleted() {
return isDeleted;
}

public boolean getIsDeleted() {
return isDeleted;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This getter is needed in order for GraphQL introspection to work properly or else startup fails. It seems to be looking for a method with "get" in the name.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this something that would be helpful to add a comment about in the code? 🤔

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good call! We wouldn't want somebody seeing there are two getters and deleting this one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why not rename the method in Eternal.java to avoid having two getters?

Copy link
Collaborator Author

@DavidMcClatchey DavidMcClatchey Dec 6, 2024

Choose a reason for hiding this comment

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

Thanks for calling that out, I'll add that now

@@ -31,11 +32,11 @@
@Component
@Slf4j
@RequiredArgsConstructor
public class AuditLoggingInstrumentation extends SimpleInstrumentation {
public class AuditLoggingInstrumentation extends SimplePerformantInstrumentation {
Copy link
Collaborator Author

@DavidMcClatchey DavidMcClatchey Dec 3, 2024

Choose a reason for hiding this comment

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

SimpleInstrumentation is deprecated in favor of SimplePerformantInstrumentation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

good to know it is performant now

@@ -406,7 +406,7 @@ void requiresPermissionAddPatientsToFacility() throws IOException {
CompletableFuture<Set<Person>> futurePatients =
this._service.savePatients(content, secondFacilityId);
ExecutionException caught = assertThrows(ExecutionException.class, futurePatients::get);
assertThat(caught.getCause().getClass()).isEqualTo(AccessDeniedException.class);
assertThat(caught.getCause().getClass()).isEqualTo(AuthorizationDeniedException.class);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

AccessDeniedException deprecated in favor of AuthorizationDeniedException

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for calling this out! I'm definitely making use of this in one of my PRs so if this goes in I'll update my usage as well!

@mehansen mehansen self-requested a review December 5, 2024 17:31
mpbrown
mpbrown previously approved these changes Dec 10, 2024
Copy link
Collaborator

@mpbrown mpbrown left a comment

Choose a reason for hiding this comment

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

Great work on this upgrade David!

DanielSass
DanielSass previously approved these changes Dec 10, 2024
@DavidMcClatchey DavidMcClatchey dismissed stale reviews from DanielSass and mpbrown via 33fff01 December 10, 2024 19:28
@DavidMcClatchey DavidMcClatchey added this pull request to the merge queue Dec 10, 2024
Merged via the queue into main with commit 3b272d0 Dec 10, 2024
34 checks passed
@DavidMcClatchey DavidMcClatchey deleted the david/spring-upgrade branch December 10, 2024 21:19
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.

Spring 3.3 Upgrade
6 participants