Skip to content

Commit a808c13

Browse files
ahmd-nabiljzheaux
authored andcommitted
Enhance IpAddressMatcher performance
Closes gh-14493 Signed-off-by: ahmd-nabil <ahm3dnabil99@gmail.com>
1 parent ee45d6c commit a808c13

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

web/src/main/java/org/springframework/security/web/util/matcher/IpAddressMatcher.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -56,8 +56,9 @@ public IpAddressMatcher(String ipAddress) {
5656
this.nMaskBits = -1;
5757
}
5858
this.requiredAddress = parseAddress(ipAddress);
59-
Assert.isTrue(this.requiredAddress.getAddress().length * 8 >= this.nMaskBits,
60-
String.format("IP address %s is too short for bitmask of length %d", ipAddress, this.nMaskBits));
59+
String finalIpAddress = ipAddress;
60+
Assert.isTrue(this.requiredAddress.getAddress().length * 8 >= this.nMaskBits, () -> String
61+
.format("IP address %s is too short for bitmask of length %d", finalIpAddress, this.nMaskBits));
6162
}
6263

6364
@Override

0 commit comments

Comments
 (0)