jerinraj5555 commented on PR #35:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/35#issuecomment-4311031026

   Thank you both for the feedback!
   
   **@cziegeler** — Applied your suggestion. Instead of the manual null-check, 
the fix now uses `.defaultValue(new String[0])` on the Converters chain:
   
   ```java
   final String[] engineNames = Converters.standardConverter()
           .convert(ref.getProperty(ScriptEngine.NAME))
           .defaultValue(new String[0])
           .to(String[].class);
   ```
   
   This is cleaner and more idiomatic with the OSGi Converters API.
   
   **@rombert** — The Spotless formatting violation has also been fixed (the 
previous ternary line break was the cause of the build failure). A Sling JIRA 
issue will be created as requested — I'll link it here once done.
   
   To clarify the problem statement: this `ClassCastException` is reproducible 
when a `BindingsValuesProvider` OSGi service does **not** set the 
`ScriptEngine.NAME` property (which is a valid and documented use case). On 
Java 21, `Converters.standardConverter().convert(null).to(String[].class)` 
returns `Object[]` instead of `String[]`, causing the cast to fail. The 
existing Jenkins CI passes because the upstream test suite does not cover this 
null-property scenario — the fix prevents the crash for services that 
legitimately omit `ScriptEngine.NAME`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to