Skip to content

Commit b1d3c1d

Browse files
authored
Merge pull request #663 from rabbitmq/require-java-11
Require at least Java 11
2 parents d541aba + dd25614 commit b1d3c1d

24 files changed

+71
-205
lines changed

Diff for: .github/workflows/publish-documentation.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Set up JDK
1212
uses: actions/setup-java@v4
1313
with:
14-
distribution: 'zulu'
14+
distribution: 'temurin'
1515
java-version: '21'
1616
cache: 'maven'
1717
- name: Publish Documentation

Diff for: .github/workflows/publish-snapshot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Set up JDK
1212
uses: actions/setup-java@v4
1313
with:
14-
distribution: 'zulu'
14+
distribution: 'temurin'
1515
java-version: '21'
1616
cache: 'maven'
1717
server-id: ossrh

Diff for: .github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
uses: actions/setup-java@v4
1616
with:
1717
distribution: 'temurin'
18-
java-version: '8'
18+
java-version: '11'
1919
cache: 'maven'
2020
server-id: ${{ env.maven_server_id }}
2121
server-username: MAVEN_USERNAME

Diff for: .github/workflows/sanity-check.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ jobs:
2323
- name: Set up JDK
2424
uses: actions/setup-java@v4
2525
with:
26-
distribution: 'zulu'
27-
java-version: '21'
26+
distribution: 'temurin'
27+
java-version: '11'
2828
cache: 'maven'
2929
- name: Start broker
3030
run: ci/start-broker.sh

Diff for: .github/workflows/test-pr.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up JDK
2020
uses: actions/setup-java@v4
2121
with:
22-
distribution: 'zulu'
22+
distribution: 'temurin'
2323
java-version: '21'
2424
cache: 'maven'
2525
- name: Start broker

Diff for: .github/workflows/test-rabbitmq-alphas.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- name: Set up JDK
2626
uses: actions/setup-java@v4
2727
with:
28-
distribution: 'zulu'
28+
distribution: 'temurin'
2929
java-version: '21'
3030
cache: 'maven'
3131
- name: Start broker

Diff for: .github/workflows/test-supported-java-versions.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
matrix:
1313
distribution: [ 'temurin' ]
14-
version: [ '8', '11', '17', '21', '23', '24-ea' ]
14+
version: [ '11', '17', '21', '23', '24-ea' ]
1515
include:
1616
- distribution: 'semeru'
1717
version: '17'

Diff for: .github/workflows/test.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- name: Set up JDK
2424
uses: actions/setup-java@v4
2525
with:
26-
distribution: 'zulu'
26+
distribution: 'temurin'
2727
java-version: '21'
2828
cache: 'maven'
2929
server-id: ossrh

Diff for: README.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ See the https://www.rabbitmq.com/client-libraries/java-versions[RabbitMQ Java li
3131

3232
=== Pre-requisites
3333

34-
This library requires at least Java 8, but Java 11 or more is recommended.
34+
This library requires at least Java 11, but Java 21 or more is recommended.
3535

3636
=== Dependencies
3737

@@ -66,7 +66,7 @@ Breaking changes between releases can happen but will be kept to a minimum.
6666

6767
== Build Instructions
6868

69-
You need JDK 8 or later installed.
69+
You need JDK 11 or later installed.
7070

7171
To build the JAR file:
7272

Diff for: pom.xml

+1-37
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,7 @@
348348
<artifactId>maven-compiler-plugin</artifactId>
349349
<version>${maven.compiler.plugin.version}</version>
350350
<configuration>
351-
<source>1.8</source>
352-
<target>1.8</target>
351+
<release>11</release>
353352
<compilerArgs>
354353
<arg>-Xlint:deprecation</arg>
355354
<arg>-Xlint:unchecked</arg>
@@ -678,16 +677,6 @@
678677
</repository>
679678
</distributionManagement>
680679
</profile>
681-
<profile>
682-
<id>mockito-4-on-java-8</id>
683-
<activation>
684-
<jdk>1.8</jdk>
685-
</activation>
686-
<properties>
687-
<mockito.version>4.11.0</mockito.version>
688-
<test-arguments>-Xshare:off</test-arguments>
689-
</properties>
690-
</profile>
691680
<profile>
692681
<id>jvm-test-arguments-below-java-21</id>
693682
<activation>
@@ -707,31 +696,6 @@
707696
</properties>
708697
</profile>
709698

710-
<profile>
711-
<!-- this avoids a compiler warning on Java 9+ -->
712-
<!-- the compiler setting is not available on Java 8 -->
713-
<id>use-release-compiler-argument-on-java-9-or-more</id>
714-
<activation>
715-
<jdk>[9,)</jdk>
716-
</activation>
717-
<build>
718-
<plugins>
719-
<plugin>
720-
<artifactId>maven-compiler-plugin</artifactId>
721-
<version>${maven.compiler.plugin.version}</version>
722-
<configuration>
723-
<source>1.8</source>
724-
<target>1.8</target>
725-
<release>8</release>
726-
<compilerArgs>
727-
<arg>-Xlint:deprecation</arg>
728-
<arg>-Xlint:unchecked</arg>
729-
</compilerArgs>
730-
</configuration>
731-
</plugin>
732-
</plugins>
733-
</build>
734-
</profile>
735699

736700
</profiles>
737701

Diff for: src/docs/asciidoc/building.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
== Building the Client
22

3-
You need JDK 1.8 or more installed.
3+
You need JDK 11 or more installed.
44

55
To build the JAR file:
66

Diff for: src/docs/asciidoc/index.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ the https://rabbitmq.com/stream.html[RabbitMQ Stream Plugin].
1111
It allows creating and deleting streams, as well as publishing to and consuming from
1212
these streams. Learn more in the <<overview.adoc#stream-client-overview,client overview>>.
1313

14-
This library requires at least Java 8, but Java 11 or more is recommended.
14+
This library requires at least Java 11, but Java 21 or more is recommended.
1515

1616
https://github.com/rabbitmq/rabbitmq-stream-perf-test[Stream PerfTest] is a performance testing tool based on this client library.
1717

Diff for: src/docs/asciidoc/overview.adoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ _These SPI are susceptible to change, but this should have no impact on most app
107107

108108
== Pre-requisites
109109

110-
This library requires at least Java 8, but Java 11 or more is recommended (CRC calculation uses methods available as of Java 9).
110+
This library requires at least Java 11, but Java 21 or more is recommended.

Diff for: src/main/java/com/rabbitmq/stream/ByteCapacity.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2023 Broadcom. All Rights Reserved.
1+
// Copyright (c) 2020-2024 Broadcom. All Rights Reserved.
22
// The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
33
//
44
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
@@ -14,8 +14,6 @@
1414
1515
package com.rabbitmq.stream;
1616

17-
import java.util.Collections;
18-
import java.util.HashMap;
1917
import java.util.Map;
2018
import java.util.Objects;
2119
import java.util.function.BiFunction;
@@ -40,15 +38,11 @@ public class ByteCapacity implements Comparable<ByteCapacity> {
4038
private static final String UNIT_TB = "tb";
4139

4240
private static final Map<String, BiFunction<Long, String, ByteCapacity>> CONSTRUCTORS =
43-
Collections.unmodifiableMap(
44-
new HashMap<String, BiFunction<Long, String, ByteCapacity>>() {
45-
{
46-
put(UNIT_KB, (size, input) -> ByteCapacity.kB(size, input));
47-
put(UNIT_MB, (size, input) -> ByteCapacity.MB(size, input));
48-
put(UNIT_GB, (size, input) -> ByteCapacity.GB(size, input));
49-
put(UNIT_TB, (size, input) -> ByteCapacity.TB(size, input));
50-
}
51-
});
41+
Map.of(
42+
UNIT_KB, ByteCapacity::kB,
43+
UNIT_MB, ByteCapacity::MB,
44+
UNIT_GB, ByteCapacity::GB,
45+
UNIT_TB, ByteCapacity::TB);
5246

5347
private final long bytes;
5448
private final String input;

Diff for: src/main/java/com/rabbitmq/stream/impl/Client.java

+18-16
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
442442

443443
private static Map<String, String> clientProperties(Map<String, String> fromParameters) {
444444
fromParameters = fromParameters == null ? Collections.emptyMap() : fromParameters;
445-
Map<String, String> clientProperties = new HashMap<>(fromParameters);
445+
Map<String, String> clientProperties = new LinkedHashMap<>(fromParameters);
446446
clientProperties.putAll(ClientProperties.DEFAULT_CLIENT_PROPERTIES);
447447
return Collections.unmodifiableMap(clientProperties);
448448
}
@@ -506,21 +506,22 @@ void authenticate(CredentialsProvider credentialsProvider) {
506506
} else if (saslAuthenticateResponse.isChallenge()) {
507507
challenge = saslAuthenticateResponse.challenge;
508508
} else if (saslAuthenticateResponse.isAuthenticationFailure()) {
509-
String message =
510-
"Unexpected response code during authentication: "
511-
+ formatConstant(saslAuthenticateResponse.getResponseCode());
509+
StringBuilder message =
510+
new StringBuilder(
511+
"Unexpected response code during authentication: "
512+
+ formatConstant(saslAuthenticateResponse.getResponseCode()));
512513
if (saslAuthenticateResponse.getResponseCode()
513514
== RESPONSE_CODE_AUTHENTICATION_FAILURE_LOOPBACK) {
514-
message +=
515-
". The user is not authorized to connect from a remote host. "
516-
+ "If the broker is running locally, make sure the '"
517-
+ this.host
518-
+ "' hostname is resolved to "
519-
+ "the loopback interface (localhost, 127.0.0.1, ::1). "
520-
+ "See https://www.rabbitmq.com/access-control.html#loopback-users.";
515+
message
516+
.append(". The user is not authorized to connect from a remote host. ")
517+
.append("If the broker is running locally, make sure the '")
518+
.append(this.host)
519+
.append("' hostname is resolved to ")
520+
.append("the loopback interface (localhost, 127.0.0.1, ::1). ")
521+
.append("See https://www.rabbitmq.com/access-control.html#loopback-users.");
521522
}
522523
throw new AuthenticationFailureException(
523-
message, saslAuthenticateResponse.getResponseCode());
524+
message.toString(), saslAuthenticateResponse.getResponseCode());
524525
} else {
525526
throw new StreamException(
526527
"Unexpected response code during authentication: "
@@ -2223,7 +2224,7 @@ static class StreamStatsResponse extends Response {
22232224

22242225
StreamStatsResponse(short responseCode, Map<String, Long> info) {
22252226
super(responseCode);
2226-
this.info = Collections.unmodifiableMap(new HashMap<>(info));
2227+
this.info = Map.copyOf(info);
22272228
}
22282229

22292230
public Map<String, Long> getInfo() {
@@ -2248,7 +2249,7 @@ public StreamMetadata(String stream, short responseCode, Broker leader, List<Bro
22482249
this.replicas =
22492250
(replicas == null || replicas.isEmpty())
22502251
? Collections.emptyList()
2251-
: Collections.unmodifiableList(replicas);
2252+
: List.copyOf(replicas);
22522253
}
22532254

22542255
public short getResponseCode() {
@@ -2263,8 +2264,9 @@ public Broker getLeader() {
22632264
return leader;
22642265
}
22652266

2267+
@SuppressFBWarnings("EI_EXPOSE_REP")
22662268
public List<Broker> getReplicas() {
2267-
return this.replicas.isEmpty() ? Collections.emptyList() : new ArrayList<>(this.replicas);
2269+
return this.replicas;
22682270
}
22692271

22702272
boolean hasReplicas() {
@@ -2561,7 +2563,7 @@ int port() {
25612563
}
25622564

25632565
Map<String, String> clientProperties() {
2564-
return Collections.unmodifiableMap(this.clientProperties);
2566+
return Map.copyOf(this.clientProperties);
25652567
}
25662568

25672569
Codec codec() {

Diff for: src/main/java/com/rabbitmq/stream/impl/ClientProperties.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2023 Broadcom. All Rights Reserved.
1+
// Copyright (c) 2020-2024 Broadcom. All Rights Reserved.
22
// The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
33
//
44
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
@@ -15,10 +15,7 @@
1515
package com.rabbitmq.stream.impl;
1616

1717
import java.io.InputStream;
18-
import java.util.Collections;
19-
import java.util.HashMap;
20-
import java.util.Map;
21-
import java.util.Properties;
18+
import java.util.*;
2219
import org.slf4j.Logger;
2320
import org.slf4j.LoggerFactory;
2421

@@ -40,7 +37,7 @@ public final class ClientProperties {
4037

4138
public static final Map<String, String> DEFAULT_CLIENT_PROPERTIES =
4239
Collections.unmodifiableMap(
43-
new HashMap<String, String>() {
40+
new LinkedHashMap<>() {
4441
{
4542
put("product", "RabbitMQ Stream");
4643
put("version", ClientProperties.VERSION);

0 commit comments

Comments
 (0)