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

Add JDK17 and springboot 3.0 support #975

Merged
merged 62 commits into from
Jan 15, 2024
Merged

Conversation

skyao
Copy link
Member

@skyao skyao commented Dec 16, 2023

Description

Upgrade to add springboot 3.0 support in dapr java sdk.

For the details, please reference to the proposal: #971

Issue reference

#971

Checklist

Please make sure you've completed the relevant tasks for this PR, out of the following list:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

skyao added 21 commits November 28, 2023 07:47
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
…o support jdk17

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
…rectory, not test source and generated source

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
@skyao skyao requested review from a team as code owners December 16, 2023 11:58
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
…ions before 3.0

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
mukundansundar
mukundansundar previously approved these changes Jan 11, 2024
Copy link
Contributor

@mukundansundar mukundansundar left a comment

Choose a reason for hiding this comment

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

lgtm. waiting for tests to pass

@artursouza
Copy link
Member

The examples should work. Rerunning it to see if it was flakiness.

@artursouza
Copy link
Member

Validation of examples is failing.

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
skyao added 13 commits January 14, 2024 09:34
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
…fklow

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
@skyao
Copy link
Member Author

skyao commented Jan 15, 2024

I'm confused by the behavior of NOP Logger and logback.

Before this PR, examples subproject in java-sdk repo depends on springboot2.x and introduced logback as its slf4j implementation:

[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:2.7.8:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:2.7.8:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:2.7.8:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.2.11:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.2.11:compile

In this PR, I updated the version of springboot to springboot 3.0, also introduced logback as its slf4j implementation:

[INFO] +- org.springframework.boot:spring-boot-starter-web:jar:3.0.13:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter:jar:3.0.13:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-logging:jar:3.0.13:compile
[INFO] |  |  |  +- ch.qos.logback:logback-classic:jar:1.4.11:compile
[INFO] |  |  |  |  \- ch.qos.logback:logback-core:jar:1.4.11:compile

But now the github action failed because of the conflicts between logback and NOP logger from slf4j-api:

		== APP == 	... 8 more
		== APP == Caused by: java.lang.IllegalArgumentException: LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logback or the competing implementation (class org.slf4j.helpers.NOPLoggerFactory loaded from jar:file:/home/runner/work/java-sdk/java-sdk/examples/target/dapr-java-sdk-examples-exec.jar!/BOOT-INF/lib/slf4j-api-1.7.25.jar!/). If you are using WebLogic you will need to add 'org.slf4j' to prefer-application-packages in WEB-INF/weblogic.xml: org.slf4j.helpers.NOPLoggerFactory

We used NOP logger in workflow, in DaprWorkflowContextImpl:

  public Logger getLogger() {
    if (this.innerContext.getIsReplaying()) {
      return NOPLogger.NOP_LOGGER;
    }
    return this.logger;
  }

The problem is that it works with jdk11 + springboot2.x (before this PR), but it doesn't work with jdk17 + springboot3.0.

I tried to exclude logback from examples subproject to fix above conflicts, then all the examples will pass exception workflow example: withtout logback, only NOP logger it can't output the text for validation.

== APP == SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
== APP == SLF4J: Defaulting to no-operation (NOP) logger implementation
== APP == SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

I also checked other examples to see why they didn't fail without logback, there are

  • using system out
  • or using java.util.logging.Logger

skyao added 2 commits January 15, 2024 10:15
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
@skyao
Copy link
Member Author

skyao commented Jan 15, 2024

Done!

   <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>2.0.9</version>
      </dependency>

After adding slf4j-api as compile dependency and upgrade its version to 2.0.9, then logback and NOP logger can work together.

@artursouza @mukundansundar This PR can be merged now!

Signed-off-by: Sky Ao <aoxiaojian@gmail.com>
Copy link

codecov bot commented Jan 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (4a7b985) 77.31% compared to head (c6df692) 77.31%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #975   +/-   ##
=========================================
  Coverage     77.31%   77.31%           
  Complexity     1537     1537           
=========================================
  Files           143      143           
  Lines          4642     4642           
  Branches        541      541           
=========================================
  Hits           3589     3589           
  Misses          778      778           
  Partials        275      275           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@artursouza artursouza merged commit 7eb24ff into dapr:master Jan 15, 2024
10 checks passed
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.

3 participants