Differences between MicroProfile Config versions

Two key sets of changes might impact the existing configuration when you upgrade to the mpConfig 2.0 feature. The changes are in the implementation and in the specification.

SmallRye implementation of the specification

Open Liberty implements the MicroProfile Config specification for application configuration from different configuration sources. In previous versions, Open Liberty implemented the specification in its own codebase.

However, for MicroProfile Config 2.0, Open Liberty consumes SmallRye implementation of the specification to produce the mpConfig 2.0 feature. Any MicroProfile Config functionality that Open Liberty implemented beyond the scope of the specification is lost from the mpConfig 2.0 feature.

AtomicInteger and AtomicLong converters no longer provided

Converters for the AtomicInteger and AtomicLong properties are no longer provided for MicroProfile Config 2.0 because these properties are not widely used. Converting an injected value to one of these types of properties might throw the exception SRCFG02006: The property yourProperty cannot be converted to class java.util.concurrent.atomic.AtomicInteger/AtomicLong. If you need to convert a String type to AtomicInteger or AtomicLong type, you can convert to Integer or Long type. Then, create an AtomicInteger or AtomicLong type from the Integer or Long type. Alternatively, you can create your own Converter for the AtomicInteger and AtomicLong properties.

In the mpConfig feature, versions 1.4 and earlier, converters are provided for AtomicInteger and AtomicLong properties.

Caching discontinued

In the mpConfig 2.0 feature, caching is discontinued. Values that are looked up from MicroProfile Config are no longer cached.

In the mpConfig feature, versions 1.4 and earlier, requests made for the same configuration key return the same object up to 5-seconds duration, without calling the configuration sources.

Converters of subtypes unavailable

In the mpConfig 2.0 feature, when a converter for a specific type is not available, converters of its subtypes cannot be used.

Converters for subtypes are available in the mpConfig feature, versions 1.4 and earlier. For example, a Converter that is registered for the type Dog extends a type Animal. When a type Animal is injected, the Dog Converter is used,

@Inject
@ConfigProperty(name = "DOG_KEY")
Animal myAnimal;

Incompatible changes

Changes in the MicroProfile Config 2.0 specification introduced some incompatibility with earlier versions. Some of these changes are by-products of new functions, and others are intentional specification clarifications and changes.

ConfigSource.getPropertyNames() no longer default method

In the MicroProfile Config 2.0 specification, ConfigSource.getPropertyNames() method is no longer a default method that is provided by the specification. Any custom configuration sources that use this method need to implement the method, otherwise a java.lang.AbstractMethodError is thrown.

In the MicroProfile Config versions 1.4 and earlier, ConfigSource.getPropertyNames() method is provided by the specification, by default.

Property expression feature

In the MicroProfile Config 2.0 specification, the number of recursion lookups is limited for composed expressions. Implementations are limited to 32. When the number of allowed lookups exceeds the limit, an IllegalArgumentException error is thrown. Variable replacement in config values is supported through the property expressions feature. This replacement allows config values to reference other config property values by using the ${} syntax with a maximum recursive depth of 32.

In MicroProfile Config , versions 1.4 and earlier, the property expression feature is not available.

Configuration property value conversion rules updated

In the MicroProfile Config 2.0 specification, configuration property value conversion rules are updated. The empty value and other special characters are no longer valid for particular return types. For example, attempting to call Config.getValue() for a config property which is defined as the empty String ("") now throws a java.util.NoSuchElementException error.

In MicroProfile Config versions 1.4 and earlier, empty value and other special characters were valid for particular return types.