File tree Expand file tree Collapse file tree 2 files changed +17
-10
lines changed
main/java/org/elasticsearch/index
test/java/org/elasticsearch/index Expand file tree Collapse file tree 2 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 1111
1212import org .elasticsearch .xcontent .XContentString ;
1313
14- import java .util .Objects ;
15-
1614import static org .elasticsearch .index .IndexSettings .IGNORE_ABOVE_DEFAULT_LOGSDB_INDICES ;
1715import static org .elasticsearch .index .IndexSettings .IGNORE_ABOVE_DEFAULT_STANDARD_INDICES ;
1816
@@ -33,8 +31,13 @@ public class IgnoreAbove {
3331 private final Integer defaultValue ;
3432
3533 public IgnoreAbove (Integer value , Integer defaultValue ) {
34+ if (value == null && defaultValue == null ) {
35+ throw new IllegalArgumentException (
36+ "IgnoreAbove must be initialized with at least one non-null argument: either 'value' or 'defaultValue'"
37+ );
38+ }
3639 this .value = value ;
37- this .defaultValue = Objects . requireNonNull ( defaultValue ) ;
40+ this .defaultValue = defaultValue ;
3841 }
3942
4043 public int get () {
Original file line number Diff line number Diff line change @@ -23,7 +23,16 @@ public void test_ignore_above_with_value_and_default() {
2323 assertTrue (ignoreAbove .isSet ());
2424 }
2525
26- public void test_ignore_above_with_default_only_is_valid () {
26+ public void test_ignore_above_with_value_only () {
27+ // given
28+ IgnoreAbove ignoreAbove = IgnoreAbove .builder ().value (123 ).build ();
29+
30+ // when/then
31+ assertEquals (123 , ignoreAbove .get ());
32+ assertTrue (ignoreAbove .isSet ());
33+ }
34+
35+ public void test_ignore_above_with_default_only () {
2736 // given
2837 IgnoreAbove ignoreAbove = IgnoreAbove .builder ().defaultValue (456 ).build ();
2938
@@ -41,14 +50,9 @@ public void test_ignore_above_with_same_value_and_default() {
4150 assertFalse (ignoreAbove .isSet ());
4251 }
4352
44- public void test_ignore_above_with_value_only_should_throw () {
45- // given/when/then
46- assertThrows (NullPointerException .class , () -> IgnoreAbove .builder ().value (123 ).build ());
47- }
48-
4953 public void test_ignore_above_with_nothing_should_throw () {
5054 // given/when/then
51- assertThrows (NullPointerException .class , () -> IgnoreAbove .builder ().build ());
55+ assertThrows (IllegalArgumentException .class , () -> IgnoreAbove .builder ().build ());
5256 }
5357
5458 public void test_string_isIgnored () {
You can’t perform that action at this time.
0 commit comments