Skip to content

SLING-13070 - ScriptContextProvider for bundled scripts does not properly set JAKARTA_REQUEST and JAKARTA_REPONSE#33

Merged
rombert merged 1 commit intomasterfrom
issue/SLING-13070
Feb 2, 2026
Merged

SLING-13070 - ScriptContextProvider for bundled scripts does not properly set JAKARTA_REQUEST and JAKARTA_REPONSE#33
rombert merged 1 commit intomasterfrom
issue/SLING-13070

Conversation

@rombert
Copy link
Contributor

@rombert rombert commented Jan 23, 2026

Use SlingBindings to ensure both javax and jakarta bindings are populated. Use the jakarta API variants to minimise wrapping.

…erly set JAKARTA_REQUEST and JAKARTA_REPONSE

Use SlingBindings to ensure both javax and jakarta bindings are populated. Use the
jakarta API variants to minimise wrapping.
@sonarqubecloud
Copy link

@enapps-enorman
Copy link
Contributor

enapps-enorman commented Jan 23, 2026

Can you provide the details or a sample on how to reproduce the error? I was under the impression that the SlingBindings would automatically provide the alternate wrapper for the jakarta or javax variants. But I may need to catch the error in a debugger to see what is happening.

@rombert
Copy link
Contributor Author

rombert commented Jan 23, 2026

Unfortunately I don't have a quick way of reproducing with the Sling Starter. It requires bundles/precompiled scripts which are used OOTB by AEM.

I am aware of https://adapt.to/2018/presentations/adaptto2018-apache-sling-scripting-reloaded-radu-cotescu-karl-pauls.pdf from @raducotescu and @karlpauls but I am not sure if there is a sample somewhere ready to be used. I found nothing in https://github.com/apache/sling-samples/ and only an old PR in ist-dresden/composum-nodes#206 .

@enapps-enorman
Copy link
Contributor

enapps-enorman commented Jan 23, 2026

Ok. Well conceptually, switching to using the SlingBindings should work to get the wrappers applied. But I wouldn't want to approve the changes without some way to verify it works in practice. Ideally some automated integration test to make sure it isn't broken again in the future. Especially since I have never used the precompiled scripts myself so I am not very familiar with the flow.

@rombert
Copy link
Contributor Author

rombert commented Jan 27, 2026

Ok. Well conceptually, switching to using the SlingBindings should work to get the wrappers applied. But I wouldn't want to approve the changes without some way to verify it works in practice. Ideally some automated integration test to make sure it isn't broken again in the future. Especially since I have never used the precompiled scripts myself so I am not very familiar with the flow.

Yes, that makes sense. I'll try and see if I can add a precompiled script to the starter tests.

Copy link
Member

@raducotescu raducotescu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to have extensive tests for bundled/precompiled scripts in https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker-it. Unfortunately, that module hasn't been maintained in a while (my fault too...), and it doesn't build with Java 17 or newer.

Given that we now ship support for bundled/precompiled scripts in our code modules, maybe we should move those tests into the starter?

@rombert
Copy link
Contributor Author

rombert commented Jan 27, 2026

Ok. Well conceptually, switching to using the SlingBindings should work to get the wrappers applied. But I wouldn't want to approve the changes without some way to verify it works in practice. Ideally some automated integration test to make sure it isn't broken again in the future. Especially since I have never used the precompiled scripts myself so I am not very familiar with the flow.

Yes, that makes sense. I'll try and see if I can add a precompiled script to the starter tests.

@enapps-enorman - I made the following changes:

Those tests are not enough to trigger the failures. They only happen when the HTL scripting engine has the scriptResolutionCache enabled. I configured in a draft PR to demonstrate the problem - apache/sling-org-apache-sling-starter#579 . I don't think we should merge it as-is because there is no out-of-the-box issue; the test should be on a lower level, which I think this PR provides.

@rombert
Copy link
Contributor Author

rombert commented Jan 27, 2026

We used to have extensive tests for bundled/precompiled scripts in https://github.com/apache/sling-org-apache-sling-scripting-bundle-tracker-it. Unfortunately, that module hasn't been maintained in a while (my fault too...), and it doesn't build with Java 17 or newer.

Given that we now ship support for bundled/precompiled scripts in our code modules, maybe we should move those tests into the starter?

Thanks for the review @raducotescu .

I added a couple of basic tests ( see my reply to Eric ). For the extensive tests I think we should follow the approach that @stefanseifert took and include the ITs in the implementation module - see Move integration tests to impl project - sling models impl because they are closer to the code they yest.

@rombert
Copy link
Contributor Author

rombert commented Jan 30, 2026

I plan to merge this on Monday, in case anyone else wants to review.

@rombert rombert merged commit 6618068 into master Feb 2, 2026
2 checks passed
@rombert rombert deleted the issue/SLING-13070 branch February 2, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants