-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Description
Expected Behavior
Given that the following String.format in IpAddressMatcher happens regardless of whether it's a valid ip address or not, there is a significant perfomance hit to doing the string formatting for even valid Ip Addresses.
Assert.isTrue(this.requiredAddress.getAddress().length * 8 >= this.nMaskBits, String.format("IP address %s is too short for bitmask of length %d", ipAddress, this.nMaskBits));
Current Behavior
It does the String.format regardless given that it's using Assert.isTrue
Context
Using an if statement or something equivalent like using the Assert.isTrue overloads with messageSupplier and only doing the format if needed for the exception should be sufficient but also doing the string formatter with something that doesn't use a pattern matcher should also be sufficient.
if (this.requiredAddress.getAddress().length * 8 < this.nMaskBits)
{
throw new IllegalArgumentException(String.format("IP address %s is too short for bitmask of length %d", ipAddress, this.nMaskBits));
}