Skip to content

IpAddressMatcher Performance #14493

Closed
@tbohnen

Description

@tbohnen

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));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: webAn issue in web modules (web, webmvc)status: ideal-for-contributionAn issue that we actively are looking for someone to help us withtype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions