Skip to content

[BUG] NPE when minBound/maxBound is not set before being called #3604

@GeorgeAp

Description

@GeorgeAp

Describe the bug
A NullPointerException occurs when the methods minBound() and maxBound

/** Get the current minimum bound that is set on this builder. */
public double minBound() {
return extendedBounds.getMin();
}
/** Get the current maximum bound that is set on this builder. */
public double maxBound() {
return extendedBounds.getMax();
}

are called before they are set in DoubleBounds

public Double getMin() {
return min;
}
public Double getMax() {
return max;
}

To Reproduce
A unit test that does not set the min and max values, example for the minBound:

public void testNPE() {
        HistogramAggregationBuilder factory = new HistogramAggregationBuilder("foo");

        try {
            factory.minBound();
        }
        catch (Exception e) {
            assertThat(e, instanceOf(NullPointerException.class));
        }
    }

Expected behavior
It should return null

Host/Environment (please complete the following information):

  • Java version : 11
  • OS: Ubuntu
  • Version 20.04.4 LTS

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingv2.1.0Issues and PRs related to version 2.1.0v3.0.0Issues and PRs related to version 3.0.0

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions