Skip to content

Commit 9169c08

Browse files
bsboddenclaude
andcommitted
fix(sentinel): address SpotBugs violations in SentinelConfig
Fixed three SpotBugs issues: 1. EI2 (Expose Internal Representation - Builder): - Added @Singular annotation to sentinelHosts field - Lombok now creates defensive copies in builder methods 2. EI (Expose Internal Representation - Getter): - Replaced @Getter with custom getSentinelHosts() method - Returns Collections.unmodifiableList() to prevent external modification 3. CT (Constructor Throws Exception): - Made HostPort class final to prevent finalizer attacks - Constructor validation now safe from subclass finalizer exploits All 350 tests pass, SpotBugs verification successful. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent fe1776f commit 9169c08

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

core/src/main/java/com/redis/vl/redis/SentinelConfig.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.redis.vl.redis;
22

33
import java.util.ArrayList;
4+
import java.util.Collections;
45
import java.util.List;
56
import lombok.Builder;
67
import lombok.Getter;
8+
import lombok.Singular;
79

810
/**
911
* Configuration for Redis Sentinel connections.
@@ -13,30 +15,38 @@
1315
*
1416
* <p>Python reference: redisvl/redis/connection.py - _parse_sentinel_url
1517
*/
16-
@Getter
1718
@Builder
1819
public class SentinelConfig {
1920

2021
/** List of Sentinel host:port pairs */
21-
private final List<HostPort> sentinelHosts;
22+
@Singular private final List<HostPort> sentinelHosts;
2223

2324
/** Sentinel service/master name (default: "mymaster") */
24-
@Builder.Default private final String serviceName = "mymaster";
25+
@Getter @Builder.Default private final String serviceName = "mymaster";
2526

2627
/** Redis database number (optional) */
27-
private final Integer database;
28+
@Getter private final Integer database;
2829

2930
/** Username for authentication (optional) */
30-
private final String username;
31+
@Getter private final String username;
3132

3233
/** Password for authentication (optional) */
33-
private final String password;
34+
@Getter private final String password;
3435

3536
/** Connection timeout in milliseconds */
36-
@Builder.Default private final int connectionTimeout = 2000;
37+
@Getter @Builder.Default private final int connectionTimeout = 2000;
3738

3839
/** Socket timeout in milliseconds */
39-
@Builder.Default private final int socketTimeout = 2000;
40+
@Getter @Builder.Default private final int socketTimeout = 2000;
41+
42+
/**
43+
* Get an unmodifiable view of the Sentinel hosts list.
44+
*
45+
* @return Unmodifiable list of Sentinel host:port pairs
46+
*/
47+
public List<HostPort> getSentinelHosts() {
48+
return Collections.unmodifiableList(sentinelHosts);
49+
}
4050

4151
/**
4252
* Parse a Sentinel URL into a SentinelConfig.
@@ -216,7 +226,7 @@ private static HostPort parseHostPort(String hostPort) {
216226

217227
/** Represents a host:port pair for Sentinel nodes */
218228
@Getter
219-
public static class HostPort {
229+
public static final class HostPort {
220230
private final String host;
221231
private final int port;
222232

0 commit comments

Comments
 (0)