Joerg Hoh created SLING-12223:
---------------------------------

             Summary: Incorrect values for OSGI properties 
(VaultDistributionPackageBuilderFactory)
                 Key: SLING-12223
                 URL: https://issues.apache.org/jira/browse/SLING-12223
             Project: Sling
          Issue Type: Task
          Components: Content Distribution
    Affects Versions: Content Distribution Core 0.5.0
            Reporter: Joerg Hoh


When changing a OSGI value for an service instance of 
VaultDistributionPackageBuilderFactory via the OSGI webconsole, I came across 
this error:

{noformat}
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]
{noformat}

And indeed the property definition for the property "MEGA_BYTES" looks like 
this:

{noformat}
    @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";
{noformat}

while the definition for the enum FileBackedMemoryOutputStream.MemoryUnit looks 
like this:

{noformat}
    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;
        }

    }
{noformat}

Meaning that the values in the property definition need adjustment to "BYTES", 
"KILO_BYTES" etc to match the enum definition.







--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to