This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-configuration.git
The following commit(s) were added to refs/heads/master by this push:
new 8f5cbe77 Use modern API
8f5cbe77 is described below
commit 8f5cbe77fb46ca5df384a827a41b4b64588cc7b4
Author: Gary Gregory <[email protected]>
AuthorDate: Wed Jul 12 19:57:59 2023 -0400
Use modern API
---
.../configuration2/spring/ConfigurationPropertySource.java | 9 +++------
.../spring/TestConfigurationPropertySource.java | 11 +++++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git
a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
index beeba6bc..f19ef8d9 100644
---
a/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
+++
b/src/main/java/org/apache/commons/configuration2/spring/ConfigurationPropertySource.java
@@ -18,10 +18,10 @@
package org.apache.commons.configuration2.spring;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.apache.commons.configuration2.Configuration;
+import org.apache.commons.lang3.ArrayUtils;
import org.springframework.core.env.EnumerablePropertySource;
/**
@@ -40,11 +40,8 @@ public class ConfigurationPropertySource extends
EnumerablePropertySource<Config
@Override
public String[] getPropertyNames() {
final List<String> keys = new ArrayList<>();
- final Iterator<String> keysIterator = source.getKeys();
- while (keysIterator.hasNext()) {
- keys.add(keysIterator.next());
- }
- return keys.toArray(new String[keys.size()]);
+ source.getKeys().forEachRemaining(keys::add);
+ return keys.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
@Override
diff --git
a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
index c37eb43e..84adf7a2 100644
---
a/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
+++
b/src/test/java/org/apache/commons/configuration2/spring/TestConfigurationPropertySource.java
@@ -34,7 +34,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
/**
- * test for ConfigurationPropertySource
+ * Tests {@link ConfigurationPropertySource}.
*/
@ExtendWith(SpringExtension.class)
@ContextConfiguration
@@ -44,7 +44,8 @@ public class TestConfigurationPropertySource {
static class Config {
@Bean
- public PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer(final ConfigurableEnvironment env) {
+ public PropertySourcesPlaceholderConfigurer
propertySourcesPlaceholderConfigurer(
+ final ConfigurableEnvironment env) {
final PropertySourcesPlaceholderConfigurer configurer = new
PropertySourcesPlaceholderConfigurer();
// https://jira.spring.io/browse/SPR-9631 may simplify this in
// future
@@ -55,13 +56,13 @@ public class TestConfigurationPropertySource {
return configurer;
}
}
+
private static final String TEST_PROPERTY = "test.property";
private static final String TEST_SYSTEM_PROPERTY = "test.system.property";
private static final String TEST_VALUE = "testVALUE";
-
private static ConfigurationPropertySource createConfigPropertySource() {
final PropertiesConfiguration propertiesConfiguration = new
PropertiesConfiguration();
propertiesConfiguration.addProperty(TEST_PROPERTY, TEST_VALUE);
@@ -91,6 +92,8 @@ public class TestConfigurationPropertySource {
}
@Test
- public void testSystemPropertyValueInjection() { assertEquals(TEST_VALUE,
systemPropertyValue); }
+ public void testSystemPropertyValueInjection() {
+ assertEquals(TEST_VALUE, systemPropertyValue);
+ }
}