Skip to content

IPAddressSeqRange.join joins upper addresses incorrectly #37

@raymundane

Description

@raymundane

Hello,

First, thanks Sean for providing and maintaining this library. It has really been a lifesaver!

I think I found a bug in IPAddressSeqRange.join.

Imagine attempting to join two ranges, 10.120.20.10 - 10.120.20.14 and 10.120.20.14 - 10.120.20.20. If the second range's lower is less than or equal to the first range's upper, then it

  1. sets the second range to null, and
  2. returns the first range, except with the first range's upper set to the second range's upper.

This results in 10.120.20.10 - 10.120.20.20, which is correct.

However, using the same logic for 10.120.20.10 - 10.120.20.20 and 10.120.20.15 - 10.120.20.15 will result in 10.120.20.10 - 10.120.20.15, which is incorrect.
Instead of always taking the second range's upper, I feel like the correct thing to do is take whichever upper is greater between the first range and the second. Thoughts?

edit: I'm using version 5.1.0 for Java 11, but I believe it is still present on 5.2.1.

edit2: Also, sidenote but I believe this method mutates the array which is passed in. Reading the javadoc, I'm not sure if this was intentional so I thought I'd mention it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions