Enhance IpAddressMatcher performance

Closes gh-14493

Signed-off-by: ahmd-nabil <ahm3dnabil99@gmail.com>
This commit is contained in:
ahmd-nabil 2024-01-27 01:02:11 +02:00 committed by Josh Cummings
parent ee45d6c685
commit a808c139ad
1 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -56,8 +56,9 @@ public final class IpAddressMatcher implements RequestMatcher {
this.nMaskBits = -1;
}
this.requiredAddress = parseAddress(ipAddress);
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));
String finalIpAddress = ipAddress;
Assert.isTrue(this.requiredAddress.getAddress().length * 8 >= this.nMaskBits, () -> String
.format("IP address %s is too short for bitmask of length %d", finalIpAddress, this.nMaskBits));
}
@Override