Skip to content

Commit

Permalink
chore: return false when peerId is blank (#1113)
Browse files Browse the repository at this point in the history
* chore: return false when peerId is ""

* Add test
  • Loading branch information
caicancai authored Jun 25, 2024
1 parent 687446e commit aefb594
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public String toString() {
*
*/
public boolean parse(final String s) {
if (StringUtils.isEmpty(s)) {
if (StringUtils.isEmpty(s) || StringUtils.isBlank(s)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@

public class PeerIdTest {

@Test
public void testToStringPeerIdFalse() {
final PeerId serverId = new PeerId();
assertFalse(serverId.parse(null));
assertFalse(serverId.parse(""));
assertFalse(serverId.parse(" "));
}

@Test
public void testToStringParse() {
final PeerId peer = new PeerId("192.168.1.1", 8081, 0);
Expand Down

0 comments on commit aefb594

Please sign in to comment.