Skip to content

Commit

Permalink
feat: support jdk 17&21 workflow (#367)
Browse files Browse the repository at this point in the history
* feat: support jdk 17&21 workflow
  • Loading branch information
funky-eyes authored Jan 22, 2025
1 parent 9f388ab commit 8a1fe47
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ jobs:

strategy:
matrix:
java-version: [8, 11]

java-version: [8, 11, 17, 21]
fail-fast: false
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java-version }}
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: 'temurin'
- name: Build with Maven
run: ./mvnw clean install -Dmaven.test.skip=true -B -U -e && bash ./.middleware-common/check_format.sh
- name: Test with Maven
Expand Down
23 changes: 21 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,10 @@
<maven.javadoc.plugin>2.9.1</maven.javadoc.plugin>
<maven.source.plugin>3.0.0</maven.source.plugin>
<maven.staging.plugin>1.6.7</maven.staging.plugin>
<maven.surefire.argLine></maven.surefire.argLine>
<maven.surefire.excludes></maven.surefire.excludes>
<maven.surefire.plugin>2.18.1</maven.surefire.plugin>
<netty.version>4.1.42.Final</netty.version>

<project.encoding>UTF-8</project.encoding>
<slf4j.version>1.7.21</slf4j.version>
<sofa.common.tools>1.4.0</sofa.common.tools>
Expand Down Expand Up @@ -198,7 +199,6 @@
<encoding>${project.encoding}</encoding>
</configuration>
</plugin>

<plugin>
<groupId>com.googlecode.maven-java-formatter-plugin</groupId>
<artifactId>maven-java-formatter-plugin</artifactId>
Expand Down Expand Up @@ -276,6 +276,8 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin}</version>
<configuration>
<argLine>${maven.surefire.argLine}</argLine>
<excludes>${maven.surefire.excludes}</excludes>
<includes>
<include>**/*Test.java</include>
</includes>
Expand Down Expand Up @@ -447,5 +449,22 @@
</plugins>
</build>
</profile>
<profile>
<id>args-for-test-by-jdk17-and-above</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<properties>
<maven.surefire.argLine>--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.net=ALL-UNNAMED
--add-opens java.base/java.math=ALL-UNNAMED
--add-opens java.base/java.text=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--add-opens java.base/java.util.regex=ALL-UNNAMED
--add-opens java.base/java.util.concurrent=ALL-UNNAMED
--add-opens java.sql/java.sql=ALL-UNNAMED
--add-opens java.sql.rowset/javax.sql.rowset.serial=ALL-UNNAMED</maven.surefire.argLine>
</properties>
</profile>
</profiles>
</project>
23 changes: 15 additions & 8 deletions src/main/java/com/alipay/remoting/util/RemotingUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,16 +193,23 @@ private static String doParse(String addr) {
if (StringUtils.isBlank(addr)) {
return StringUtils.EMPTY;
}
if (addr.charAt(0) == '/') {
return addr.substring(1);
} else {
int len = addr.length();
for (int i = 1; i < len; ++i) {
if (addr.charAt(i) == '/') {
return addr.substring(i + 1);
// Find the first and second '/' positions
int firstSlash = addr.indexOf('/');
int secondSlash = addr.indexOf('/', firstSlash + 1);
if (firstSlash != -1) {
if (secondSlash != -1) {
// Extract the IP address and port
String ip = addr.substring(firstSlash + 1, secondSlash);
String port = addr.substring(secondSlash + 1);
if (port.contains(":")) {
port = port.split(":")[1];
}
return ip + ":" + port;
} else {
// Only one slash, return the part after the slash
return addr.substring(firstSlash + 1);
}
return addr;
}
return addr;
}
}

0 comments on commit 8a1fe47

Please sign in to comment.