|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2023 the original author or authors. |
| 2 | + * Copyright 2012-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
17 | 17 | package org.springframework.boot.env;
|
18 | 18 |
|
19 | 19 | import java.nio.charset.StandardCharsets;
|
20 |
| -import java.util.Collections; |
21 | 20 | import java.util.List;
|
22 | 21 | import java.util.Map;
|
23 | 22 |
|
@@ -115,18 +114,19 @@ void processListOfMaps() {
|
115 | 114 | void processEmptyAndNullValues() {
|
116 | 115 | OriginTrackedValue empty = getValue("empty");
|
117 | 116 | OriginTrackedValue nullValue = getValue("null-value");
|
| 117 | + OriginTrackedValue emptyList = getValue("emptylist"); |
118 | 118 | assertThat(empty.getValue()).isEqualTo("");
|
119 | 119 | assertThat(getLocation(empty)).isEqualTo("27:8");
|
120 | 120 | assertThat(nullValue.getValue()).isEqualTo("");
|
121 | 121 | assertThat(getLocation(nullValue)).isEqualTo("28:13");
|
| 122 | + assertThat(emptyList.getValue()).isEqualTo(""); |
| 123 | + assertThat(getLocation(emptyList)).isEqualTo("29:12"); |
122 | 124 | }
|
123 | 125 |
|
124 | 126 | @Test
|
125 |
| - void processEmptyListAndMap() { |
126 |
| - OriginTrackedValue emptymap = getValue("emptymap"); |
127 |
| - OriginTrackedValue emptylist = getValue("emptylist"); |
128 |
| - assertThat(emptymap.getValue()).isEqualTo(Collections.emptyMap()); |
129 |
| - assertThat(emptylist.getValue()).isEqualTo(Collections.emptyList()); |
| 127 | + void emptyMapsAreDropped() { |
| 128 | + Object emptyMap = getValue("emptymap"); |
| 129 | + assertThat(emptyMap).isNull(); |
130 | 130 | }
|
131 | 131 |
|
132 | 132 | @Test
|
@@ -194,11 +194,12 @@ void canLoadFilesBiggerThan3Mb() {
|
194 | 194 | assertThat(loaded).isNotEmpty();
|
195 | 195 | }
|
196 | 196 |
|
197 |
| - private OriginTrackedValue getValue(String name) { |
| 197 | + @SuppressWarnings("unchecked") |
| 198 | + private <T> T getValue(String name) { |
198 | 199 | if (this.result == null) {
|
199 | 200 | this.result = this.loader.load();
|
200 | 201 | }
|
201 |
| - return (OriginTrackedValue) this.result.get(0).get(name); |
| 202 | + return (T) this.result.get(0).get(name); |
202 | 203 | }
|
203 | 204 |
|
204 | 205 | private String getLocation(OriginTrackedValue value) {
|
|
0 commit comments