Search code examples
javatimeguavaintersection

java package com.google.common.collect.Range< LocalDate > intersection returns a wrong intersection


I have this code:

private Range<LocalDate> datesRange;

and

intersection = !this.datesRange.isConnected(otherConditionBl.datesRange) ?
                    null :
                    this.datesRange.intersection(otherConditionBl.datesRange);

how come there is an intersection for this input?

this.datesRange = {Range@5802} "[2017-04-11..2017-04-12)"
otherConditionBl.datesRange = {Range@5801} "[2017-04-12..2017-04-14]"
this.datesRange.intersection(otherConditionBl.datesRange) = {Range@7036} "[2017-04-12..2017-04-12)"

Where can i report a bug for this?


Solution

  • This is documented behaviour.

    The resulting range may be empty; for example, [1..5) intersected with [5..7) yields the empty range [5..5)

    If you look closely, the range returned is actually empty. It consists of all dates x such, that 2017-04-12x < 2017-04-12, which is impossible to satisfy.