Skip to content

Build modules using Java 8 #10817

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

Conversation

marcusdacoregio
Copy link
Contributor

This PR does the following:

  • Revert the commit 60ed360 that was used as a workaround;
  • Fix Fix OAuth2ResourceServerConfigurer member variable using Java 9+ feature #10695 by creating a static method to initialize the handlers;
  • Use Java 8 for all modules but OpenSAML4;
  • Because the Saml2Login/LogoutConfigurerTests are using some OpenSAML4 classes, these tests have to be compiled using Java 11. For this, those tests were removed from the compileTestJava task and a new Gradle task compileSaml2TestJava is being used to compile them;
  • Another task saml2Tests is being used to run the tests compiled by compileSaml2TestJava.
  • Instead of using the ModuleDescriptor to retrieve the OpenSAML version, now we are checking if the class org.opensaml.core.xml.persist.impl.PassthroughSourceStrategy exists in the classpath. This class was introduced in OpenSAML4.

@marcusdacoregio marcusdacoregio added status: duplicate A duplicate of another issue in: build An issue in the build type: enhancement A general enhancement labels Feb 8, 2022
@marcusdacoregio marcusdacoregio self-assigned this Feb 8, 2022
@marcusdacoregio marcusdacoregio changed the title Build modules using Java 8 #10816 Build modules using Java 8 Feb 8, 2022
@marcusdacoregio marcusdacoregio marked this pull request as ready for review February 8, 2022 12:57
Copy link
Contributor

@jzheaux jzheaux left a comment

Choose a reason for hiding this comment

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

Thanks, @marcusdacoregio! I've left my feedback inline.

@@ -130,3 +129,33 @@ tasks.withType(KotlinCompile).configureEach {
}

build.dependsOn rncToXsd

compileTestJava {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it true that we don't want to run these tests against JDK 8? It seems to me that we want to run the tests twice: Once for JDK 8 and once for JDK 11.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to run they using JDK 11 only because they are using OpenSAML4 classes

}
else {
return new OpenSamlAuthenticationRequestFactory();
if (ClassUtils.isPresent("org.opensaml.core.xml.persist.impl.PassthroughSourceStrategy",
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if it would still be appropriate to have a version() method for readability. It would simply determine the version via ClassUtils.isPresent.

else {
return new OpenSamlAuthenticationRequestFactory();
if (ClassUtils.isPresent("org.opensaml.core.xml.persist.impl.PassthroughSourceStrategy",
Version.class.getClassLoader())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels a little odd to be calling for Version's classloader given that we aren't working with the Version class. I wonder if passing null here would be better.

}
return this.logoutResponseResolver;
if (ClassUtils.isPresent("org.opensaml.core.xml.persist.impl.PassthroughSourceStrategy",
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more readable to have one place for all the decision logic. Right now there is some here and some in OpenSaml4LogoutSupportFactory

@@ -519,4 +512,38 @@ public void logout(HttpServletRequest request, HttpServletResponse response, Aut

}

private static class OpenSaml4LogoutSupportFactory {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this class still necessary? I think it was necessary when it was acting as a classpath guard. However, since you are using reflection now, I don't think this class offers this same benefit.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those classes make the code cleaner by moving the try-catch from the reflective operations to another method

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import sun.security.x509.X500Name;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you clarify how these changes pertain to the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those changes came from the revert that I did to the old commit, where we weren't using toolchain to build the modules

This causes compile errors when trying to build using JDK 8

Issue spring-projectsgh-10695
Because the OpenSAML4 classes are compiled using Java 11, we have to rely on reflection to instante those classes since the config module should be compatible with Java 8

Issue spring-projectsgh-10816
@marcusdacoregio marcusdacoregio changed the base branch from 5.7.x to 5.8.x June 2, 2022 17:05
@marcusdacoregio marcusdacoregio merged commit 3dd54bc into spring-projects:5.8.x Jun 2, 2022
This was referenced Jun 2, 2022
@marcusdacoregio marcusdacoregio modified the milestones: 5.8.x, 5.8.0-M1 Jun 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: build An issue in the build status: duplicate A duplicate of another issue type: enhancement A general enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build modules using Java 8 Fix OAuth2ResourceServerConfigurer member variable using Java 9+ feature
3 participants