|
2 | 2 |
|
3 | 3 | import lombok.AllArgsConstructor; |
4 | 4 | import lombok.Builder; |
5 | | -import lombok.NoArgsConstructor; |
6 | 5 | import lombok.Setter; |
7 | 6 |
|
8 | 7 | import java.util.Map; |
|
17 | 16 | */ |
18 | 17 | @Setter |
19 | 18 | @Builder |
20 | | -@NoArgsConstructor |
21 | 19 | @AllArgsConstructor |
22 | 20 | public class ZaiConfig { |
23 | 21 |
|
@@ -128,12 +126,30 @@ public class ZaiConfig { |
128 | 126 | @Builder.Default |
129 | 127 | private String source_channel = "java-sdk"; |
130 | 128 |
|
| 129 | + /** |
| 130 | + * No-arg constructor that mirrors all {@link Builder.Default} field values. Lombok's |
| 131 | + * {@code @NoArgsConstructor} does not apply {@code @Builder.Default} values, so we |
| 132 | + * write this constructor explicitly to ensure every field starts with the same |
| 133 | + * defaults as the builder. |
| 134 | + */ |
| 135 | + public ZaiConfig() { |
| 136 | + this.expireMillis = 30 * 60 * 1000; |
| 137 | + this.alg = "HS256"; |
| 138 | + this.disableTokenCache = true; |
| 139 | + this.connectionPoolMaxIdleConnections = 5; |
| 140 | + this.connectionPoolKeepAliveDuration = 10; |
| 141 | + this.connectionPoolTimeUnit = TimeUnit.SECONDS; |
| 142 | + this.timeOutTimeUnit = TimeUnit.SECONDS; |
| 143 | + this.source_channel = "java-sdk"; |
| 144 | + } |
| 145 | + |
131 | 146 | /** |
132 | 147 | * Constructor with combined API secret key. |
133 | 148 | * @param apiKey combined secret key in format {apiKey}.{apiSecret} |
134 | 149 | * @throws RuntimeException if apiSecretKey format is invalid |
135 | 150 | */ |
136 | 151 | public ZaiConfig(String apiKey) { |
| 152 | + this(); |
137 | 153 | this.apiKey = apiKey; |
138 | 154 | String[] arrStr = apiKey.split("\\."); |
139 | 155 | if (arrStr.length != 2) { |
@@ -251,7 +267,7 @@ public int getConnectionPoolMaxIdleConnections() { |
251 | 267 | * variable fallback. |
252 | 268 | */ |
253 | 269 | public long getConnectionPoolKeepAliveDuration() { |
254 | | - if (connectionPoolKeepAliveDuration != 1) { // If not default value |
| 270 | + if (connectionPoolKeepAliveDuration != 10) { // If not default value |
255 | 271 | return connectionPoolKeepAliveDuration; |
256 | 272 | } |
257 | 273 | String propValue = System.getProperty(ENV_CONNECTION_POOL_KEEP_ALIVE); |
|
0 commit comments