mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Support ConfigMemorySize in fromAnyRef
We don't preserve its "memory-size-ness" but we can parse it into a Long.
This commit is contained in:
parent
2e43d9b21c
commit
97718593c6
@ -18,6 +18,7 @@ import java.util.concurrent.Callable;
|
||||
import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigException;
|
||||
import com.typesafe.config.ConfigIncluder;
|
||||
import com.typesafe.config.ConfigMemorySize;
|
||||
import com.typesafe.config.ConfigObject;
|
||||
import com.typesafe.config.ConfigOrigin;
|
||||
import com.typesafe.config.ConfigParseOptions;
|
||||
@ -273,6 +274,8 @@ public class ConfigImpl {
|
||||
}
|
||||
|
||||
return new SimpleConfigList(origin, values);
|
||||
} else if (object instanceof ConfigMemorySize) {
|
||||
return new ConfigLong(origin, ((ConfigMemorySize) object).toBytes(), null);
|
||||
} else {
|
||||
throw new ConfigException.BugOrBroken(
|
||||
"bug in method caller: not valid to create ConfigValue from: "
|
||||
|
@ -169,6 +169,12 @@ class PublicApiTest extends TestUtils {
|
||||
assertEquals("foo", ConfigValueFactory.fromIterable(treeSet, "foo").origin().description())
|
||||
}
|
||||
|
||||
@Test
|
||||
def fromConfigMemorySize() {
|
||||
testFromValue(longValue(1024), ConfigMemorySize.ofBytes(1024));
|
||||
testFromValue(longValue(512), ConfigMemorySize.ofBytes(512));
|
||||
}
|
||||
|
||||
@Test
|
||||
def roundTripUnwrap() {
|
||||
val conf = ConfigFactory.load("test01")
|
||||
|
Loading…
Reference in New Issue
Block a user