Skip to content

Commit 7c49e8b

Browse files
committed
Not allow empty username
Signed-off-by: yhmo <yihua.mo@zilliz.com>
1 parent 8b60823 commit 7c49e8b

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

sdk-core/src/main/java/io/milvus/param/ConnectParam.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,9 @@ public Builder withRpcDeadline(long deadline, TimeUnit timeUnit) {
491491
* @return <code>Builder</code>
492492
*/
493493
public Builder withAuthorization(String username, String password) {
494+
if (username == null || username.trim().isEmpty()) {
495+
throw new IllegalArgumentException("Username cannot be null or blank");
496+
}
494497
this.authorization = Base64.getEncoder().encodeToString(String.format("%s:%s", username, password).getBytes(StandardCharsets.UTF_8));
495498
this.userName = username;
496499
return this;

sdk-core/src/main/java/io/milvus/v2/client/ConnectConfig.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,9 @@ public ConnectConfigBuilder token(String token) {
354354
}
355355

356356
public ConnectConfigBuilder username(String username) {
357+
if (username == null || username.trim().isEmpty()) {
358+
throw new IllegalArgumentException("Username cannot be null or blank");
359+
}
357360
this.username = username;
358361
return this;
359362
}

0 commit comments

Comments
 (0)