Skip to content

Commit b15be3d

Browse files
author
chengyitian
committed
AJ-732: fix issue about pool minimumPoolSize、maximumPoolSize; optimize some log info about pool;
1 parent 1b25dd4 commit b15be3d

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/com/xxdb/SimpleDBConnectionPoolConfig.java

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ protected void validate() {
178178
hostName = getNullIfEmpty(hostName);
179179
if (Objects.isNull(hostName)) {
180180
hostName = "localhost";
181-
log.warn("The param hostName not set, use the default value 'localhost'");
181+
log.warn("The param hostName not set, will use the default value 'localhost'");
182182
}
183183

184184
if (!checkHostNameValid(hostName))
185185
throw new RuntimeException(String.format("Invalid hostName: %s", hostName));
186186

187187
if (port <= 0) {
188188
port = 8848;
189-
log.warn("Invalid port, use the default value 8848.");
189+
log.warn("Invalid port, will use the default value 8848.");
190190
}
191191

192192
userId = getNullIfEmpty(userId);
@@ -203,7 +203,7 @@ protected void validate() {
203203

204204
if (initialPoolSize <= 0) {
205205
initialPoolSize = 5;
206-
log.warn("The number of connection pools is invalid, use the default value 5.");
206+
log.warn("The number of connection pools is invalid, will use the default value 5.");
207207
}
208208

209209
if (initialPoolSize > 0 && minimumPoolSize == -1 && maximumPoolSize == -1) {
@@ -214,36 +214,34 @@ protected void validate() {
214214

215215
if (initialPoolSize < 0) {
216216
// 新逻辑(不填init,如果mini、max也不填,这俩参数给默认值,填了照常取值但是要做判断):mini、max 不填的话,自动设置默认值
217-
if (minimumPoolSize < 0 && maximumPoolSize < 0) {
217+
if (minimumPoolSize <= 0 && maximumPoolSize <= 0) {
218218
minimumPoolSize = 5;
219-
log.warn("The param 'minimumIdle' cannot less than or equal to 0, use the default value 5.");
219+
log.warn("The param 'minimumIdle' cannot less than or equal to 0, will use the default value 5.");
220220

221221
maximumPoolSize = 5;
222-
log.warn("The param 'maximumPoolSize' cannot less than or equal to 0, use the default value 5.");
222+
log.warn("The param 'maximumPoolSize' cannot less than or equal to 0, will use the default value 5.");
223223
} else if (minimumPoolSize > 0 && maximumPoolSize > 0) {
224224
if (maximumPoolSize < minimumPoolSize) {
225225
maximumPoolSize = minimumPoolSize;
226226
log.warn("The param 'maximumPoolSize' cannot less than 'minimumIdle', 'maximumPoolSize' will be set equal to 'minimumIdle' value.");
227227
}
228228
}
229229
} else {
230-
if (minimumPoolSize < 0 && maximumPoolSize < 0) {
230+
if (minimumPoolSize <= 0) {
231231
minimumPoolSize = 5;
232-
log.warn("The param 'minimumIdle' cannot less than or equal to 0, use the default value 5.");
233-
232+
log.warn("The param 'minimumIdle' cannot less than or equal to 0, will use the default value 5.");
233+
} else if (maximumPoolSize <= 0) {
234234
maximumPoolSize = 5;
235-
log.warn("The param 'maximumPoolSize' cannot less than or equal to 0, use the default value 5.");
236-
} else if (minimumPoolSize > 0 && maximumPoolSize > 0) {
237-
if (maximumPoolSize < minimumPoolSize) {
235+
log.warn("The param 'maximumPoolSize' cannot less than or equal to 0, will use the default value 5.");
236+
} else if (maximumPoolSize < minimumPoolSize) {
238237
maximumPoolSize = minimumPoolSize;
239238
log.warn("The param 'maximumPoolSize' cannot less than 'minimumIdle', 'maximumPoolSize' will be set equal to 'minimumIdle' value.");
240-
}
241239
}
242240
}
243241

244242
if (idleTimeout < 10000) {
245243
idleTimeout = 600000;
246-
log.warn("The param 'idleTimeout' cannot less than 10000ms, use the default value 600000ms(10min)");
244+
log.warn("The param 'idleTimeout' cannot less than 10000ms, will use the default value 600000ms(10min)");
247245
}
248246
}
249247

0 commit comments

Comments
 (0)