|
55 | 55 | import com.rabbitmq.stream.sasl.SaslConfiguration;
|
56 | 56 | import com.rabbitmq.stream.sasl.SaslMechanism;
|
57 | 57 | import com.rabbitmq.stream.sasl.UsernamePasswordCredentialsProvider;
|
| 58 | +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; |
58 | 59 | import io.netty.bootstrap.Bootstrap;
|
59 | 60 | import io.netty.buffer.ByteBuf;
|
60 | 61 | import io.netty.buffer.ByteBufAllocator;
|
@@ -194,10 +195,12 @@ public long applyAsLong(Object value) {
|
194 | 195 | private final boolean filteringSupported;
|
195 | 196 | private final Runnable superStreamManagementCommandVersionsCheck;
|
196 | 197 |
|
| 198 | + @SuppressFBWarnings("CT_CONSTRUCTOR_THROW") |
197 | 199 | public Client() {
|
198 | 200 | this(new ClientParameters());
|
199 | 201 | }
|
200 | 202 |
|
| 203 | + @SuppressFBWarnings("CT_CONSTRUCTOR_THROW") |
201 | 204 | public Client(ClientParameters parameters) {
|
202 | 205 | this.publishConfirmListener = parameters.publishConfirmListener;
|
203 | 206 | this.publishErrorListener = parameters.publishErrorListener;
|
@@ -1678,7 +1681,7 @@ String serverAdvertisedHost() {
|
1678 | 1681 | }
|
1679 | 1682 |
|
1680 | 1683 | int serverAdvertisedPort() {
|
1681 |
| - return Integer.valueOf(this.connectionProperties("advertised_port")); |
| 1684 | + return Integer.parseInt(this.connectionProperties("advertised_port")); |
1682 | 1685 | }
|
1683 | 1686 |
|
1684 | 1687 | public String brokerVersion() {
|
@@ -2233,7 +2236,7 @@ public StreamMetadata(String stream, short responseCode, Broker leader, List<Bro
|
2233 | 2236 | this.stream = stream;
|
2234 | 2237 | this.responseCode = responseCode;
|
2235 | 2238 | this.leader = leader;
|
2236 |
| - this.replicas = replicas; |
| 2239 | + this.replicas = replicas == null ? null : Collections.unmodifiableList(replicas); |
2237 | 2240 | }
|
2238 | 2241 |
|
2239 | 2242 | public short getResponseCode() {
|
@@ -2679,12 +2682,16 @@ public StreamParametersBuilder maxLengthTb(long teraBytes) {
|
2679 | 2682 | }
|
2680 | 2683 |
|
2681 | 2684 | public StreamParametersBuilder maxSegmentSizeBytes(long bytes) {
|
2682 |
| - this.parameters.put("stream-max-segment-size-bytes", String.valueOf(bytes)); |
| 2685 | + if (bytes <= 0) { |
| 2686 | + this.parameters.remove("stream-max-segment-size-bytes"); |
| 2687 | + } else { |
| 2688 | + this.parameters.put("stream-max-segment-size-bytes", String.valueOf(bytes)); |
| 2689 | + } |
2683 | 2690 | return this;
|
2684 | 2691 | }
|
2685 | 2692 |
|
2686 | 2693 | public StreamParametersBuilder maxSegmentSizeBytes(ByteCapacity bytes) {
|
2687 |
| - return maxSegmentSizeBytes(bytes.toBytes()); |
| 2694 | + return maxSegmentSizeBytes(bytes == null ? 0L : bytes.toBytes()); |
2688 | 2695 | }
|
2689 | 2696 |
|
2690 | 2697 | public StreamParametersBuilder maxSegmentSizeKb(long kiloBytes) {
|
@@ -2733,7 +2740,7 @@ public StreamParametersBuilder put(String key, String value) {
|
2733 | 2740 | }
|
2734 | 2741 |
|
2735 | 2742 | public Map<String, String> build() {
|
2736 |
| - return parameters; |
| 2743 | + return new HashMap<>(parameters); |
2737 | 2744 | }
|
2738 | 2745 | }
|
2739 | 2746 |
|
|
0 commit comments