Skip to content

Require at least Java 11 #663

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

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Publish Documentation
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
cache: 'maven'
server-id: ossrh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
java-version: '11'
cache: 'maven'
server-id: ${{ env.maven_server_id }}
server-username: MAVEN_USERNAME
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sanity-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'
distribution: 'temurin'
java-version: '11'
cache: 'maven'
- name: Start broker
run: ci/start-broker.sh
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Start broker
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-rabbitmq-alphas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
cache: 'maven'
- name: Start broker
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-supported-java-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
distribution: [ 'temurin' ]
version: [ '8', '11', '17', '21', '23', '24-ea' ]
version: [ '11', '17', '21', '23', '24-ea' ]
include:
- distribution: 'semeru'
version: '17'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v4
with:
distribution: 'zulu'
distribution: 'temurin'
java-version: '21'
cache: 'maven'
server-id: ossrh
Expand Down
4 changes: 2 additions & 2 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ See the https://www.rabbitmq.com/client-libraries/java-versions[RabbitMQ Java li

=== Pre-requisites

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

=== Dependencies

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

== Build Instructions

You need JDK 8 or later installed.
You need JDK 11 or later installed.

To build the JAR file:

Expand Down
38 changes: 1 addition & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>11</release>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:unchecked</arg>
Expand Down Expand Up @@ -678,16 +677,6 @@
</repository>
</distributionManagement>
</profile>
<profile>
<id>mockito-4-on-java-8</id>
<activation>
<jdk>1.8</jdk>
</activation>
<properties>
<mockito.version>4.11.0</mockito.version>
<test-arguments>-Xshare:off</test-arguments>
</properties>
</profile>
<profile>
<id>jvm-test-arguments-below-java-21</id>
<activation>
Expand All @@ -707,31 +696,6 @@
</properties>
</profile>

<profile>
<!-- this avoids a compiler warning on Java 9+ -->
<!-- the compiler setting is not available on Java 8 -->
<id>use-release-compiler-argument-on-java-9-or-more</id>
<activation>
<jdk>[9,)</jdk>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
<compilerArgs>
<arg>-Xlint:deprecation</arg>
<arg>-Xlint:unchecked</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</profile>

</profiles>

Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/building.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
== Building the Client

You need JDK 1.8 or more installed.
You need JDK 11 or more installed.

To build the JAR file:

Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ the https://rabbitmq.com/stream.html[RabbitMQ Stream Plugin].
It allows creating and deleting streams, as well as publishing to and consuming from
these streams. Learn more in the <<overview.adoc#stream-client-overview,client overview>>.

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

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

Expand Down
2 changes: 1 addition & 1 deletion src/docs/asciidoc/overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -107,4 +107,4 @@ _These SPI are susceptible to change, but this should have no impact on most app

== Pre-requisites

This library requires at least Java 8, but Java 11 or more is recommended (CRC calculation uses methods available as of Java 9).
This library requires at least Java 11, but Java 21 or more is recommended.
18 changes: 6 additions & 12 deletions src/main/java/com/rabbitmq/stream/ByteCapacity.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Broadcom. All Rights Reserved.
// Copyright (c) 2020-2024 Broadcom. All Rights Reserved.
// The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
//
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
Expand All @@ -14,8 +14,6 @@
// [email protected].
package com.rabbitmq.stream;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
Expand All @@ -40,15 +38,11 @@ public class ByteCapacity implements Comparable<ByteCapacity> {
private static final String UNIT_TB = "tb";

private static final Map<String, BiFunction<Long, String, ByteCapacity>> CONSTRUCTORS =
Collections.unmodifiableMap(
new HashMap<String, BiFunction<Long, String, ByteCapacity>>() {
{
put(UNIT_KB, (size, input) -> ByteCapacity.kB(size, input));
put(UNIT_MB, (size, input) -> ByteCapacity.MB(size, input));
put(UNIT_GB, (size, input) -> ByteCapacity.GB(size, input));
put(UNIT_TB, (size, input) -> ByteCapacity.TB(size, input));
}
});
Map.of(
UNIT_KB, ByteCapacity::kB,
UNIT_MB, ByteCapacity::MB,
UNIT_GB, ByteCapacity::GB,
UNIT_TB, ByteCapacity::TB);

private final long bytes;
private final String input;
Expand Down
34 changes: 18 additions & 16 deletions src/main/java/com/rabbitmq/stream/impl/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)

private static Map<String, String> clientProperties(Map<String, String> fromParameters) {
fromParameters = fromParameters == null ? Collections.emptyMap() : fromParameters;
Map<String, String> clientProperties = new HashMap<>(fromParameters);
Map<String, String> clientProperties = new LinkedHashMap<>(fromParameters);
clientProperties.putAll(ClientProperties.DEFAULT_CLIENT_PROPERTIES);
return Collections.unmodifiableMap(clientProperties);
}
Expand Down Expand Up @@ -506,21 +506,22 @@ void authenticate(CredentialsProvider credentialsProvider) {
} else if (saslAuthenticateResponse.isChallenge()) {
challenge = saslAuthenticateResponse.challenge;
} else if (saslAuthenticateResponse.isAuthenticationFailure()) {
String message =
"Unexpected response code during authentication: "
+ formatConstant(saslAuthenticateResponse.getResponseCode());
StringBuilder message =
new StringBuilder(
"Unexpected response code during authentication: "
+ formatConstant(saslAuthenticateResponse.getResponseCode()));
if (saslAuthenticateResponse.getResponseCode()
== RESPONSE_CODE_AUTHENTICATION_FAILURE_LOOPBACK) {
message +=
". The user is not authorized to connect from a remote host. "
+ "If the broker is running locally, make sure the '"
+ this.host
+ "' hostname is resolved to "
+ "the loopback interface (localhost, 127.0.0.1, ::1). "
+ "See https://www.rabbitmq.com/access-control.html#loopback-users.";
message
.append(". The user is not authorized to connect from a remote host. ")
.append("If the broker is running locally, make sure the '")
.append(this.host)
.append("' hostname is resolved to ")
.append("the loopback interface (localhost, 127.0.0.1, ::1). ")
.append("See https://www.rabbitmq.com/access-control.html#loopback-users.");
}
throw new AuthenticationFailureException(
message, saslAuthenticateResponse.getResponseCode());
message.toString(), saslAuthenticateResponse.getResponseCode());
} else {
throw new StreamException(
"Unexpected response code during authentication: "
Expand Down Expand Up @@ -2223,7 +2224,7 @@ static class StreamStatsResponse extends Response {

StreamStatsResponse(short responseCode, Map<String, Long> info) {
super(responseCode);
this.info = Collections.unmodifiableMap(new HashMap<>(info));
this.info = Map.copyOf(info);
}

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

public short getResponseCode() {
Expand All @@ -2263,8 +2264,9 @@ public Broker getLeader() {
return leader;
}

@SuppressFBWarnings("EI_EXPOSE_REP")
public List<Broker> getReplicas() {
return this.replicas.isEmpty() ? Collections.emptyList() : new ArrayList<>(this.replicas);
return this.replicas;
}

boolean hasReplicas() {
Expand Down Expand Up @@ -2561,7 +2563,7 @@ int port() {
}

Map<String, String> clientProperties() {
return Collections.unmodifiableMap(this.clientProperties);
return Map.copyOf(this.clientProperties);
}

Codec codec() {
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/com/rabbitmq/stream/impl/ClientProperties.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2023 Broadcom. All Rights Reserved.
// Copyright (c) 2020-2024 Broadcom. All Rights Reserved.
// The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
//
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
Expand All @@ -15,10 +15,7 @@
package com.rabbitmq.stream.impl;

import java.io.InputStream;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

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

public static final Map<String, String> DEFAULT_CLIENT_PROPERTIES =
Collections.unmodifiableMap(
new HashMap<String, String>() {
new LinkedHashMap<>() {
{
put("product", "RabbitMQ Stream");
put("version", ClientProperties.VERSION);
Expand Down
Loading