Skip to content

Commit

Permalink
1. explicit return added to more clearly show that empty list has spe…
Browse files Browse the repository at this point in the history
…cial treatment

2. reformatted code
  • Loading branch information
zeldigas committed Jun 28, 2020
1 parent c6ff8fb commit 5c57b27
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -16,7 +15,7 @@ public class Application {
private AppConfig appConfig;

@RequestMapping("/config")
AppConfig config(){
AppConfig config() {
return appConfig;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class SubConfiguration {

private List<String> endpoints;

private Map<String,Object> connectionSettings;
private Map<String, Object> connectionSettings;

public List<String> getEndpoints() {
return endpoints;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private void addConfigValuePropertyTo(Map<String, Object> properties, String key
private void processListValue(Map<String, Object> properties, String key, Resource resource, ConfigList value) {
if (value.isEmpty()) {
addConfigValuePropertyTo(properties, key, resource, ConfigValueFactory.fromAnyRef(""));
return;
}

for (int i = 0; i < value.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class HoconPropertySourceLoader implements PropertySourceLoader {

@Override
public String[] getFileExtensions() {
return new String[] {"conf"};
return new String[]{"conf"};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void verifyPropertyValuesAreSame(EnumerablePropertySource<?> hoconParse,
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
private <T extends PropertySource<?>> T loadProperties(PropertySourceLoader propertySourceLoader, String path) throws IOException {
List<PropertySource<?>> source = propertySourceLoader.load("hocon", new ClassPathResource(path));
assertThat("One property source expected", source.size(), is(1));
Expand All @@ -54,7 +54,7 @@ private <T extends PropertySource<?>> T loadProperties(PropertySourceLoader prop
@Test
public void propertyOriginIsCorrectlyDetermined() throws IOException {
OriginTrackedMapPropertySource hoconParse = loadProperties(new HoconPropertySourceLoader(), "/application.conf");

verifyPropertyHasOriginOnLine(hoconParse, "spring.datasource.url", 3);
verifyPropertyHasOriginOnLine(hoconParse, "server.port", 9);
verifyPropertyHasOriginOnLine(hoconParse, "myApp.configuration.connectionSettings.two.two_sub", 20);
Expand Down

0 comments on commit 5c57b27

Please sign in to comment.