Details
-
Task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Content Distribution Core 0.5.0
-
None
Description
When changing a OSGI value for an service instance of VaultDistributionPackageBuilderFactory via the OSGI webconsole, I came across this error:
08.01.2024 14:57:00.773 *ERROR* [FelixLogListener] org.apache.sling.distribution.serialization.impl.vlt.VaultDistributionPackageBuilderFactory bundle org.apache.sling.distribution.core:0.5.0 (334)[or g.apache.sling.distribution.serialization.impl.vlt.VaultDistributionPackageBuilderFactory(1167)] : The activate method has thrown an exception (java.lang.IllegalArgumentException: No enum constant org.apache.sling.distrib ution.util.impl.FileBackedMemoryOutputStream.MemoryUnit.Bytes) java.lang.IllegalArgumentException: No enum constant org.apache.sling.distribution.util.impl.FileBackedMemoryOutputStream.MemoryUnit.Bytes at java.base/java.lang.Enum.valueOf(Enum.java:240) at org.apache.sling.distribution.util.impl.FileBackedMemoryOutputStream$MemoryUnit.valueOf(FileBackedMemoryOutputStream.java:41) [org.apache.sling.distribution.core:0.5.0] at org.apache.sling.distribution.serialization.impl.vlt.VaultDistributionPackageBuilderFactory.activate(VaultDistributionPackageBuilderFactory.java:267) [org.apache.sling.distribution.core:0.5.0] at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:245) [org.apache.felix.scr:2.2.4]
And indeed the property definition for the property "MEGA_BYTES" looks like this:
@Property( label = "The memory unit for the file threshold", description = "The memory unit for the file threshold, Megabytes by default", value = DEFAULT_MEMORY_UNIT, options = { @PropertyOption(name = "BYTES", value = "Bytes"), @PropertyOption(name = "KILO_BYTES", value = "Kilobytes"), @PropertyOption(name = "MEGA_BYTES", value = "Megabytes"), @PropertyOption(name = "GIGA_BYTES", value = "Gigabytes") } ) private static final String MEMORY_UNIT = "MEGA_BYTES";
while the definition for the enum FileBackedMemoryOutputStream.MemoryUnit looks like this:
public enum MemoryUnit { BYTES(1), KILO_BYTES(1000), MEGA_BYTES((int) pow(10, 6)), GIGA_BYTES((int) pow(10, 9)); private final int memoryFactor; MemoryUnit(int memoryFactor) { this.memoryFactor = memoryFactor; } }
Meaning that the values in the property definition need adjustment to "BYTES", "KILO_BYTES" etc to match the enum definition.