diff --git a/.github/workflows/dubbo-3_2.yml b/.github/workflows/dubbo-3_2.yml index 3d3f1dd1bc..3664f87b07 100644 --- a/.github/workflows/dubbo-3_2.yml +++ b/.github/workflows/dubbo-3_2.yml @@ -34,6 +34,8 @@ jobs: runs-on: ubuntu-latest strategy: fail-fast: false + matrix: + java: [ '8', '17' ] steps: - uses: actions/checkout@v1 - name: Cache local Maven repository @@ -43,13 +45,18 @@ jobs: key: ${{ runner.os }}-samples-maven-${{ hashFiles('**/pom.xml') }} restore-keys: | ${{ runner.os }}-samples-maven- - - name: Set up JDK 8 + - name: Set up JDK ${{ matrix.Java }} uses: actions/setup-java@v1 with: - java-version: 8 - - name: Build with Maven + java-version: ${{ matrix.Java }} + - name: Build for compiler 8 with Maven + if: matrix.java == '8' + run: | + ./mvnw $BUILD_OPTS -pl "-:dubbo-samples-spring-boot-consumer","-:dubbo-samples-spring-boot-provider","-:dubbo-samples-spring-boot-interface","-:dubbo-samples-spring-boot" + - name: Build for compiler 17 with Maven + if: matrix.java == '17' run: | - ./mvnw $BUILD_OPTS + ./mvnw $BUILD_OPTS -pl "+:dubbo-samples-spring-boot-consumer","+:dubbo-samples-spring-boot-provider" -am build-dubbo: runs-on: ubuntu-latest diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/pom.xml b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/pom.xml index 827f1fcc77..43819dc665 100644 --- a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/pom.xml +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/pom.xml @@ -26,11 +26,6 @@ 4.0.0 dubbo-samples-spring-boot-consumer - - 1.7.25 - 2.3.1.RELEASE - - org.apache.dubbo @@ -60,11 +55,6 @@ org.springframework.boot spring-boot-starter - - org.springframework.boot - spring-boot-autoconfigure - - diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/src/main/resources/application.yml b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/src/main/resources/application.yml index 9f29958e6e..29e349d525 100644 --- a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/src/main/resources/application.yml +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/src/main/resources/application.yml @@ -27,3 +27,10 @@ dubbo: address: zookeeper://127.0.0.1:2181 metadata-report: address: zookeeper://127.0.0.1:2181 + service: + org: + apache: + dubbo: + springboot: + demo: + serialization: fastjson2 diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/pom.xml b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/pom.xml index 21d56c63ca..3a97596960 100644 --- a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/pom.xml +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/pom.xml @@ -24,7 +24,6 @@ ../pom.xml 4.0.0 - dubbo-samples-spring-boot-provider @@ -56,11 +55,6 @@ org.springframework.boot spring-boot-starter - - org.springframework.boot - spring-boot-autoconfigure - - diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/EmbeddedZooKeeper.java b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/EmbeddedZooKeeper.java index c6b40bd213..3cf8a20979 100644 --- a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/EmbeddedZooKeeper.java +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/EmbeddedZooKeeper.java @@ -23,7 +23,6 @@ import org.slf4j.LoggerFactory; import org.springframework.context.SmartLifecycle; import org.springframework.util.ErrorHandler; -import org.springframework.util.SocketUtils; import java.io.File; import java.lang.reflect.Method; @@ -85,7 +84,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle { * Construct an EmbeddedZooKeeper with a random port. */ public EmbeddedZooKeeper() { - clientPort = SocketUtils.findAvailableTcpPort(); + clientPort = TestSocketUtils.findAvailableTcpPort(); } /** diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/TestSocketUtils.java b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/TestSocketUtils.java new file mode 100644 index 0000000000..35ee00ce70 --- /dev/null +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/java/org/apache/dubbo/springboot/demo/provider/TestSocketUtils.java @@ -0,0 +1,109 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.dubbo.springboot.demo.provider; + +import java.net.InetAddress; +import java.net.ServerSocket; +import java.util.Random; + +import javax.net.ServerSocketFactory; + +import org.apache.dubbo.common.utils.Assert; + +/** + * Simple utility for finding available TCP ports on {@code localhost} for use in + * integration testing scenarios. + * + *

{@code TestSocketUtils} can be used in integration tests which start an + * external server on an available random port. However, these utilities make no + * guarantee about the subsequent availability of a given port and are therefore + * unreliable. Instead of using {@code TestSocketUtils} to find an available local + * port for a server, it is recommended that you rely on a server's ability to + * start on a random ephemeral port that it selects or is assigned by the + * operating system. To interact with that server, you should query the server + * for the port it is currently using. + * + * @since 3.2 + */ +public class TestSocketUtils { + + /** + * The minimum value for port ranges used when finding an available TCP port. + */ + static final int PORT_RANGE_MIN = 1024; + + /** + * The maximum value for port ranges used when finding an available TCP port. + */ + static final int PORT_RANGE_MAX = 65535; + + private static final int PORT_RANGE_PLUS_ONE = PORT_RANGE_MAX - PORT_RANGE_MIN + 1; + + private static final int MAX_ATTEMPTS = 1_000; + + private static final Random random = new Random(System.nanoTime()); + + private static final TestSocketUtils INSTANCE = new TestSocketUtils(); + + private TestSocketUtils() { + } + + /** + * Find an available TCP port randomly selected from the range [1024, 65535]. + * @return an available TCP port number + * @throws IllegalStateException if no available port could be found + */ + public static int findAvailableTcpPort() { + return INSTANCE.findAvailableTcpPortInternal(); + } + + + /** + * Internal implementation of {@link #findAvailableTcpPort()}. + *

Package-private solely for testing purposes. + */ + int findAvailableTcpPortInternal() { + int candidatePort; + int searchCounter = 0; + do { + Assert.assertTrue(++searchCounter <= MAX_ATTEMPTS, String.format( + "Could not find an available TCP port in the range [%d, %d] after %d attempts", + PORT_RANGE_MIN, PORT_RANGE_MAX, MAX_ATTEMPTS)); + candidatePort = PORT_RANGE_MIN + random.nextInt(PORT_RANGE_PLUS_ONE); + } + while (!isPortAvailable(candidatePort)); + + return candidatePort; + } + + /** + * Determine if the specified TCP port is currently available on {@code localhost}. + *

Package-private solely for testing purposes. + */ + boolean isPortAvailable(int port) { + try { + ServerSocket serverSocket = ServerSocketFactory.getDefault() + .createServerSocket(port, 1, InetAddress.getByName("localhost")); + serverSocket.close(); + return true; + } + catch (Exception ex) { + return false; + } + } + +} diff --git a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/resources/application.yml b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/resources/application.yml index 37a249fdcc..24dc62758e 100644 --- a/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/resources/application.yml +++ b/1-basic/dubbo-samples-spring-boot/dubbo-samples-spring-boot-provider/src/main/resources/application.yml @@ -27,3 +27,10 @@ dubbo: address: zookeeper://127.0.0.1:2181 metadata-report: address: zookeeper://127.0.0.1:2181 + service: + org: + apache: + dubbo: + springboot: + demo: + serialization: fastjson2 diff --git a/1-basic/dubbo-samples-spring-boot/pom.xml b/1-basic/dubbo-samples-spring-boot/pom.xml index d558cc3e81..d7132bb298 100644 --- a/1-basic/dubbo-samples-spring-boot/pom.xml +++ b/1-basic/dubbo-samples-spring-boot/pom.xml @@ -109,10 +109,28 @@ maven-compiler-plugin 3.7.0 - 1.8 - 1.8 + ${maven.compiler.source} + ${maven.compiler.target} + + + + jdk17ge + + [17,) + + + 17 + 17 + 6.0.2 + 3.2.0-beta.2 + 4.13.2 + 3.0.0 + 3.0.0 + + + diff --git a/test/dubbo-test-runner/src/docker/Dockerfile b/test/dubbo-test-runner/src/docker/Dockerfile index f21b8948dc..1311e8cd86 100644 --- a/test/dubbo-test-runner/src/docker/Dockerfile +++ b/test/dubbo-test-runner/src/docker/Dockerfile @@ -14,7 +14,7 @@ # limitations under the License. ARG JAVA_VER=8 -FROM openjdk:$JAVA_VER +FROM eclipse-temurin:$JAVA_VER ARG DEBIAN_MIRROR RUN if [ -n "$DEBIAN_MIRROR" ]; then \