From 252b1994d9165b2637d9b0fca7dbc0ce06246616 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Wed, 18 Aug 2021 22:10:59 +0200 Subject: [PATCH 01/11] Upgrade Mockito to latest version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index de742fc0a3..4821bde1bd 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ org.mockito mockito-core - 3.6.0 + 3.11.2 test From 9c53a8491de88e1c7c4835057e2d3953780aa0d7 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Wed, 18 Aug 2021 22:15:05 +0200 Subject: [PATCH 02/11] Run GitHub Actions on Java 11 and 16 --- .github/workflows/build.yml | 5 ++++- .github/workflows/validate.yml | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7ea05cf33..4e49b3e5b6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,12 +16,15 @@ on: jobs: build: runs-on: ubuntu-latest + strategy: + matrix: + java: [ 11, 16 ] env: GOVER: 1.15.0 GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org - JDK_VER: 13.0.x + JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.3.0-rc.1 DAPR_RUNTIME_VER: 1.3.0-rc.1 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/v1.3.0-rc.1/install/install.sh diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 6b67f229f9..e72929e230 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -21,12 +21,15 @@ on: jobs: validate: runs-on: ubuntu-latest + strategy: + matrix: + java: [ 11, 16 ] env: GOVER: 1.15.0 GOOS: linux GOARCH: amd64 GOPROXY: https://proxy.golang.org - JDK_VER: 13.0.x + JDK_VER: ${{ matrix.java }} DAPR_CLI_VER: 1.3.0-rc.1 DAPR_RUNTIME_VER: 1.3.0-rc.1 DAPR_INSTALL_URL: https://raw.githubusercontent.com/dapr/cli/3dacfb672d55f1436c249057aaebbe597e1066f3/install/install.sh From 1e6336900cf2ac98054438ffcaf68cae9d10e8d4 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Wed, 18 Aug 2021 22:39:37 +0200 Subject: [PATCH 03/11] Run JUnit tests with `--add-opens java.base/java.util=ALL-UNNAMED` --- sdk/pom.xml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sdk/pom.xml b/sdk/pom.xml index db8530271e..788972348c 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -128,6 +128,14 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.22.2 + + --add-opens java.base/java.util=ALL-UNNAMED + + org.apache.maven.plugins maven-javadoc-plugin From 86ce154c7f977de4c58d4e95360944a2e158b26d Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Thu, 19 Aug 2021 08:30:32 +0200 Subject: [PATCH 04/11] Move Surefire JVM arguments to Maven property --- sdk/pom.xml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sdk/pom.xml b/sdk/pom.xml index 788972348c..9461567bb6 100644 --- a/sdk/pom.xml +++ b/sdk/pom.xml @@ -30,6 +30,9 @@ false 1.39.0 + + --add-opens java.base/java.util=ALL-UNNAMED + @@ -128,14 +131,6 @@ - - org.apache.maven.plugins - maven-surefire-plugin - 2.22.2 - - --add-opens java.base/java.util=ALL-UNNAMED - - org.apache.maven.plugins maven-javadoc-plugin From 8cf53dd089f01160daf0c8cc3419aba29707e43b Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Fri, 20 Aug 2021 14:59:16 -0700 Subject: [PATCH 05/11] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e49b3e5b6..bce6eb45e4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 11, 16 ] + java: [ 11, 13, 15, 16 ] env: GOVER: 1.15.0 GOOS: linux From a5b27561978c01f183d763dab9eb516d8c447462 Mon Sep 17 00:00:00 2001 From: Artur Souza Date: Fri, 20 Aug 2021 14:59:41 -0700 Subject: [PATCH 06/11] Update validate.yml --- .github/workflows/validate.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index e72929e230..c15c39ce1c 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -23,7 +23,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - java: [ 11, 16 ] + java: [ 11, 13, 15, 16 ] env: GOVER: 1.15.0 GOOS: linux From adf32528cf72980436c0d0bc9de20267af130dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B5=A9?= Date: Sat, 21 Aug 2021 07:21:40 +0800 Subject: [PATCH 07/11] simplily build singleton dapr http (#590) Co-authored-by: Artur Souza --- .../main/java/io/dapr/client/DaprHttpBuilder.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java index 26ed5e999a..7c0d3c6c58 100644 --- a/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java +++ b/sdk/src/main/java/io/dapr/client/DaprHttpBuilder.java @@ -9,7 +9,6 @@ import okhttp3.OkHttpClient; import java.time.Duration; -import java.util.concurrent.atomic.AtomicReference; /** * A builder for the DaprHttp. @@ -19,7 +18,7 @@ public class DaprHttpBuilder { /** * Singleton OkHttpClient. */ - private static final AtomicReference OK_HTTP_CLIENT = new AtomicReference<>(); + private static volatile OkHttpClient OK_HTTP_CLIENT; /** * Static lock object. @@ -42,18 +41,17 @@ public DaprHttp build() { * @return Instance of {@link DaprHttp} */ private DaprHttp buildDaprHttp() { - if (OK_HTTP_CLIENT.get() == null) { + if (OK_HTTP_CLIENT == null) { synchronized (LOCK) { - if (OK_HTTP_CLIENT.get() == null) { + if (OK_HTTP_CLIENT == null) { OkHttpClient.Builder builder = new OkHttpClient.Builder(); Duration readTimeout = Duration.ofSeconds(Properties.HTTP_CLIENT_READ_TIMEOUT_SECONDS.get()); builder.readTimeout(readTimeout); - OkHttpClient okHttpClient = builder.build(); - OK_HTTP_CLIENT.set(okHttpClient); + OK_HTTP_CLIENT = builder.build(); } } } - return new DaprHttp(Properties.SIDECAR_IP.get(), Properties.HTTP_PORT.get(), OK_HTTP_CLIENT.get()); + return new DaprHttp(Properties.SIDECAR_IP.get(), Properties.HTTP_PORT.get(), OK_HTTP_CLIENT); } } From 321fedeec3596cb39470c80dbd27c89291622de2 Mon Sep 17 00:00:00 2001 From: Tom Cools Date: Sat, 21 Aug 2021 03:27:33 +0200 Subject: [PATCH 08/11] Add Automerge workflow (#605) * Add Automerge workflow The automerge workflow will check for complete and approved pull requests and will merge them automatically. Sources: - For the python script to execute the merge: https://raw.githubusercontent.com/dapr/dapr/master/.github/scripts/automerge.py (only changed the label from "automerge" to "auto-merge") - https://raw.githubusercontent.com/dapr/dapr/master/.github/workflows/dapr-bot-schedule.yml (only copied the automerge part, not the prune_stale part as that was not part of the issue. Resolves https://github.com/dapr/java-sdk/issues/603 * Update automerge-bot.yml * Update automerge-bot.yml Co-authored-by: Artur Souza --- .github/scripts/automerge.py | 60 +++++++++++++++++++++++++++++ .github/workflows/automerge-bot.yml | 26 +++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 .github/scripts/automerge.py create mode 100644 .github/workflows/automerge-bot.yml diff --git a/.github/scripts/automerge.py b/.github/scripts/automerge.py new file mode 100644 index 0000000000..3518579d9d --- /dev/null +++ b/.github/scripts/automerge.py @@ -0,0 +1,60 @@ +# ------------------------------------------------------------ +# Copyright (c) Microsoft Corporation and Dapr Contributors. +# Licensed under the MIT License. +# ------------------------------------------------------------ + +# This script automerges PRs + +import os + +from github import Github + + +g = Github(os.getenv("GITHUB_TOKEN")) +repo = g.get_repo(os.getenv("GITHUB_REPOSITORY")) +maintainers = [m.strip() for m in os.getenv("MAINTAINERS").split(',')] + +def fetch_pulls(mergeable_state): + return [pr for pr in repo.get_pulls(state='open', sort='created') \ + if pr.mergeable_state == mergeable_state and 'auto-merge' in [l.name for l in pr.labels]] + +def is_approved(pr): + approvers = [r.user.login for r in pr.get_reviews() if r.state == 'APPROVED' and r.user.login in maintainers] + return len([a for a in approvers if repo.get_collaborator_permission(a) in ['admin', 'write']]) > 0 + +# First, find a PR that can be merged +pulls = fetch_pulls('clean') +print(f"Detected {len(pulls)} open pull requests in {repo.name} to be automerged.") +merged = False +for pr in pulls: + if is_approved(pr): + # Merge only one PR per run. + print(f"Merging PR {pr.html_url}") + try: + pr.merge(merge_method='squash') + merged = True + break + except: + print(f"Failed to merge PR {pr.html_url}") + +if len(pulls) > 0 and not merged: + print("No PR was automerged.") + +# Now, update all PRs that are behind. +pulls = fetch_pulls('behind') +print(f"Detected {len(pulls)} open pull requests in {repo.name} to be updated.") +for pr in pulls: + if is_approved(pr): + # Update all PRs since there is no guarantee they will all pass. + print(f"Updating PR {pr.html_url}") + try: + pr.update_branch() + except: + print(f"Failed to update PR {pr.html_url}") + +pulls = fetch_pulls('dirty') +print(f"Detected {len(pulls)} open pull requests in {repo.name} to be automerged but are in dirty state.") +for pr in pulls: + print(f"PR is in dirty state: {pr.html_url}") + +print("Done.") \ No newline at end of file diff --git a/.github/workflows/automerge-bot.yml b/.github/workflows/automerge-bot.yml new file mode 100644 index 0000000000..554e0ce5f4 --- /dev/null +++ b/.github/workflows/automerge-bot.yml @@ -0,0 +1,26 @@ +# ------------------------------------------------------------ +# Copyright (c) Microsoft Corporation and Dapr Contributors. +# Licensed under the MIT License. +# ------------------------------------------------------------ + +name: dapr-java-sdk-automerge-bot + +on: + schedule: + - cron: '*/30 * * * *' + workflow_dispatch: +jobs: + automerge: + if: github.repository_owner == 'dapr' + name: Automerge and update PRs. + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v2 + - name: Install dependencies + run: pip install PyGithub + - name: Automerge and update + env: + MAINTAINERS: artursouza,mukundansundar + GITHUB_TOKEN: ${{ secrets.DAPR_BOT_TOKEN }} + run: python ./.github/scripts/automerge.py From 5bebefeb1081fcb9f7fdacf5fab0d1d6dcb0a37c Mon Sep 17 00:00:00 2001 From: Tom Cools Date: Sat, 21 Aug 2021 04:07:31 +0200 Subject: [PATCH 09/11] Cleanup Maven POM files (#604) Added fixed versions for maven-deploy-plugin & spring-boot-maven-plugin as this would otherwise break in a future maven version. Also fixed some indenting and removed duplicate declarations. Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com> --- examples/pom.xml | 6 ++---- pom.xml | 43 +++++++++++++++++++++++++----------------- sdk-springboot/pom.xml | 33 +++++++++++++------------------- 3 files changed, 41 insertions(+), 41 deletions(-) diff --git a/examples/pom.xml b/examples/pom.xml index 8393795164..9635944ff1 100644 --- a/examples/pom.xml +++ b/examples/pom.xml @@ -10,7 +10,6 @@ 1.2.0-SNAPSHOT - io.dapr dapr-sdk-examples jar 1.2.0-SNAPSHOT @@ -97,13 +96,10 @@ org.junit.jupiter junit-jupiter - RELEASE - compile org.mockito mockito-core - 3.6.0 compile @@ -175,6 +171,7 @@ org.apache.maven.plugins maven-deploy-plugin + ${maven-deploy-plugin.version} true @@ -190,6 +187,7 @@ org.springframework.boot spring-boot-maven-plugin + ${springboot.version} diff --git a/pom.xml b/pom.xml index 4821bde1bd..99ccc89227 100644 --- a/pom.xml +++ b/pom.xml @@ -20,12 +20,15 @@ 1.6.2 3.1.1 1.8 + 2.7 8 8 true + true 4.0.0-RC1 true + 2.3.5.RELEASE @@ -64,6 +67,12 @@ 4.13.1 test + + org.junit.jupiter + junit-jupiter + 5.7.2 + test + org.mockito mockito-core @@ -76,23 +85,23 @@ - org.jacoco - jacoco-maven-plugin - 0.8.6 - - - - prepare-agent - - - - report - test - - report - - - + org.jacoco + jacoco-maven-plugin + 0.8.6 + + + + prepare-agent + + + + report + test + + report + + + org.apache.maven.plugins diff --git a/sdk-springboot/pom.xml b/sdk-springboot/pom.xml index a5ce8c158f..337d77cc2a 100644 --- a/sdk-springboot/pom.xml +++ b/sdk-springboot/pom.xml @@ -65,12 +65,12 @@ mockito-core test - - com.github.gmazzo - okhttp-mock - 1.3.2 - test - + + com.github.gmazzo + okhttp-mock + 1.3.2 + test + org.junit.jupiter junit-jupiter-api @@ -83,24 +83,18 @@ 5.2.10.RELEASE compile - - org.springframework - spring-web - 5.2.10.RELEASE - compile - org.springframework spring-web 5.2.10.RELEASE compile - - org.springframework - spring-context - 5.2.10.RELEASE - compile - + + org.springframework + spring-context + 5.2.10.RELEASE + compile + org.springframework.boot spring-boot-autoconfigure @@ -174,7 +168,7 @@ BUNDLE - + LINE COVEREDRATIO 80% @@ -184,7 +178,6 @@ - From 19c587595cc5f19ac7c72e25210c33c76f418eb7 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 21 Aug 2021 04:37:18 +0200 Subject: [PATCH 10/11] Add support for @PostMapping("/path") to pub/sub topic subscriptions (#583) * Remove duplicate dependency * Transform into managed dependencies * Remove old JUnit version from dependencies * Add tests for DaprBeanPostProcessor * Also register PostMappings that use value * Modify existing pub/sub test to no use @PostMapping(path="...") * Remove added dependencies on AssertJ, Spring Test and Servlet API * Remove test in favour of the sdk-tests one Co-authored-by: Artur Souza --- sdk-springboot/pom.xml | 7 ------- .../java/io/dapr/springboot/DaprBeanPostProcessor.java | 4 +++- .../java/io/dapr/it/pubsub/http/SubscriberController.java | 2 +- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sdk-springboot/pom.xml b/sdk-springboot/pom.xml index 337d77cc2a..2a26fe0b12 100644 --- a/sdk-springboot/pom.xml +++ b/sdk-springboot/pom.xml @@ -55,11 +55,6 @@ dapr-sdk-actors ${project.version} - - junit - junit - test - org.mockito mockito-core @@ -74,13 +69,11 @@ org.junit.jupiter junit-jupiter-api - 5.5.2 test org.springframework spring-beans - 5.2.10.RELEASE compile diff --git a/sdk-springboot/src/main/java/io/dapr/springboot/DaprBeanPostProcessor.java b/sdk-springboot/src/main/java/io/dapr/springboot/DaprBeanPostProcessor.java index 9cb0c56c02..53040b050f 100644 --- a/sdk-springboot/src/main/java/io/dapr/springboot/DaprBeanPostProcessor.java +++ b/sdk-springboot/src/main/java/io/dapr/springboot/DaprBeanPostProcessor.java @@ -21,7 +21,7 @@ import java.util.Map; /** - * Handles Dapr annotations in Springboot Controllers. + * Handles Dapr annotations in Spring Controllers. */ @Component public class DaprBeanPostProcessor implements BeanPostProcessor { @@ -77,6 +77,8 @@ private static void subscribeToTopics(Class clazz, EmbeddedValueResolver embedde if (mapping != null && mapping.path() != null && mapping.path().length >= 1) { route = mapping.path()[0]; + } else if (mapping != null && mapping.value() != null && mapping.value().length >= 1) { + route = mapping.value()[0]; } String topicName = embeddedValueResolver.resolveStringValue(topic.name()); diff --git a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/SubscriberController.java b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/SubscriberController.java index 619eb0f412..cb9d3a2f9c 100644 --- a/sdk-tests/src/test/java/io/dapr/it/pubsub/http/SubscriberController.java +++ b/sdk-tests/src/test/java/io/dapr/it/pubsub/http/SubscriberController.java @@ -35,7 +35,7 @@ public List> getMessagesByTopic(@PathVariable("topic") String topi } @Topic(name = "testingtopic", pubsubName = "messagebus") - @PostMapping(path = "/route1") + @PostMapping("/route1") public Mono handleMessage(@RequestBody(required = false) CloudEvent envelope) { return Mono.fromRunnable(() -> { try { From 821f3ac1aa18a854ed7cc2a0907109852d0860c4 Mon Sep 17 00:00:00 2001 From: Maarten Mulders Date: Sat, 21 Aug 2021 22:17:26 +0200 Subject: [PATCH 11/11] Run JUnit tests in all modules with java.base/java.util and java.base/java.lang opened to all modules --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 99ccc89227..01a0f2a4e3 100644 --- a/pom.xml +++ b/pom.xml @@ -29,6 +29,8 @@ 4.0.0-RC1 true 2.3.5.RELEASE + + --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED