[GitHub] [sling-org-apache-sling-models-impl] kwin commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


kwin commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803385353



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Just unget the service reference in `deactivate` and at the same time 
remove it from the reference queue.




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] sagarmiglani commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


sagarmiglani commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803384095



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Hi Kwin, Thanks for the comment. I agree that NPE, IAE or any other 
runtime exception should not be caught unless we can recover safely from it. 
But point was here to let the dispose the all references present in the queue 
(0) at once (if present). I will remove the NPE and IAE from catch block. I 
have tried to explain the scenario in JIRA (1).
   
   Whenever we use a model (let's a M in Bundle B) with OSGi service injection 
and use the model in a page.. OSGiServices are injected into the model and for 
disposing these injected references ModelAdapterFactory keeps PhantomReferences 
with reference queue (see ModelAdapterFactory for more details (2)). This queue 
is checked every 30 seconds (default), to disposes these references. And if 
Bundle B is refreshed (restarted) before the references were disposed, while 
disposing these references (context.ungetService(ref)) we get ISE: Invalid 
Bundle Context. which stops the current job trigger and the next reference is 
picked in the next job trigger.
   
   Please let me If I am missing something.
   
   0: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L210
   1: https://issues.apache.org/jira/browse/SLING-11132
   2: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java

##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Hi Kwin, Thanks for the comment. I agree that NPE, IAE or any other 
runtime exception should not be caught unless we can recover safely from it. 
But point was here to let the dispose the all references present in the queue 
(0) at once (if present). I will remove the NPE and IAE from catch block. I 
have tried to explain the scenario in JIRA (1).
   
   Whenever we use a model (let's a M in Bundle B) with OSGi service injection 
and use the model in a page.. OSGiServices are injected into the model and for 
disposing these injected references ModelAdapterFactory keeps PhantomReferences 
with reference queue (see ModelAdapterFactory for more details (2)). This queue 
is checked every 30 seconds (default), to disposes these references. And if 
Bundle B is refreshed (restarted) before the references were disposed, while 
disposing these references (context.ungetService(ref)) we get ISE: Invalid 
Bundle Context. which stops the current job trigger and the next reference is 
picked in the next job trigger.
   
   Please let me know If I am missing something.
   
   0: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L210
   1: https://issues.apache.org/jira/browse/SLING-11132
   2: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] sagarmiglani commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


sagarmiglani commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803384095



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Hi Kwin, Thanks for the comment. I agree that NPE, IAE or any other 
runtime exception should not be caught unless we can recover safely from it. 
But point was here to let the dispose the all references present in the queue 
[0] at once (if present). I will remove the NPE and IAE from catch block. I 
have tried to explain the scenario in JIRA [1].
   
   Whenever we use a model (let's a M in Bundle B) with OSGi service injection 
and use the model in a page.. OSGiServices are injected into the model and for 
disposing these injected references ModelAdapterFactory keeps PhantomReferences 
with reference queue (see ModelAdapterFactory for more details [2]). This queue 
is checked every 30 seconds (default), to disposes these references. And if 
Bundle B is refreshed (restarted) before the references were disposed, while 
disposing these references (context.ungetService(ref)) we get ISE: Invalid 
Bundle Context. which stops the current job trigger and the next reference is 
picked in the next job trigger.
   
   Please let me If I am missing something.
   
   [0]: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L210
   [1]: https://issues.apache.org/jira/browse/SLING-11132
   [2]: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] sagarmiglani commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


sagarmiglani commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803384095



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Hi Kwin, Thanks for the comment. I agree that NPE, IAE or any other 
runtime exception should not be caught unless we can recover safely from it. 
But point here it to let the dispose the all references present in the queue 
[0] at once (if present). I will remove the NPE and IAE from catch block. I 
have tried to explain the scenario in JIRA [1].
   
   Whenever we use a model (let's a M in Bundle B) with OSGi service injection 
and use the model in a page.. OSGiServices are injected into the model and for 
disposing these injected references ModelAdapterFactory keeps PhantomReferences 
with reference queue (see ModelAdapterFactory for more details [2]). This queue 
is checked every 30 seconds (default), to disposes these references. And if 
Bundle B is refreshed (restarted) before the references were disposed, while 
disposing these references (context.ungetService(ref)) we get ISE: Invalid 
Bundle Context. which stops the current job trigger and the next reference is 
picked in the next job trigger.
   
   Please let me If I am missing something.
   
   [0]: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L210
   [1]: https://issues.apache.org/jira/browse/SLING-11132
   [2]: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] kwin commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


kwin commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803367825



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   NPE should never been caught. That hints at a mistake in the code. 




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] kwin commented on pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


kwin commented on pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#issuecomment-1034575972


   According to the bug description it seems much better to just add a 
deactivate method in the injector and do a proper cleanup there.


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] kwin commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


kwin commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803367825



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   NPE should never been caught. That hints at a mistake in the code. Same 
for IAE according to 
https://docs.osgi.org/javadoc/osgi.core/7.0.0/org/osgi/framework/BundleContext.html#ungetService-org.osgi.framework.ServiceReference-.
 Only catching ISE might make sense here, although it is not really clear to me 
how this can happen




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-models-impl] sonarcloud[bot] commented on pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


sonarcloud[bot] commented on pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#issuecomment-1034539080


   Kudos, SonarCloud Quality Gate passed!  ![Quality Gate 
passed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/passed-16px.png
 'Quality Gate passed')
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-models-impl=34=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-models-impl=34=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-models-impl=34=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=CODE_SMELL)
 [0 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-models-impl=34=false=CODE_SMELL)
   
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/0-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-models-impl=34=new_coverage=list)
 [0.0% 
Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-models-impl=34=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-models-impl=34=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-models-impl=34=new_duplicated_lines_density=list)
   
   


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Commented] (SLING-11132) Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread Sagar Miglani (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11132?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17489980#comment-17489980
 ] 

Sagar Miglani commented on SLING-11132:
---

PR link: [https://github.com/apache/sling-org-apache-sling-models-impl/pull/34]

Added a try - catch block.

> Exception handling while clearing OSGiServiceReferences
> ---
>
> Key: SLING-11132
> URL: https://issues.apache.org/jira/browse/SLING-11132
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Affects Versions: Models Implementation 1.5.0
>Reporter: Sagar Miglani
>Priority: Major
>  Time Spent: 10m
>  Remaining Estimate: 0h
>
> *"Sling Models OSGi Service Disposal Job"* to clean the OSGi service 
> references does not do any error handling.
> If a ungetting of a reference [0] is failed due to some exception (like 
> java.lang.IllegalStateException: Invalid BundleContext) no more references 
> present in queue are cleaned up in same job trigger. The next reference in 
> queue will be tried after 30 seconds (default) in next job trigger. 
> Therefore, it may take an hour to clean up 120 references with an error.
> To reproduce this:
>  # Create a model consisting of OSGiService Injection
>  # Use this model in a page
>  # Open the created page and refresh it couple of time (10-15)
>  # Restart the bundle with model created in step 1
>  # One may see the following exceptions in the logs (after every ~30 seconds 
> to clear up the OSGi service references)
> {code:xml}
> 01.02.2021 14:31:03.639 *ERROR* [sling-default-1-Sling Models OSGi Service 
> Disposal Job] org.apache.sling.commons.scheduler.impl.QuartzScheduler 
> Exception during job execution of job 
> 'org.apache.sling.models.impl.ModelAdapterFactory@1b834b3c' with name 'Sling 
> Models OSGi Service Disposal Job' : Invalid BundleContext.
> java.lang.IllegalStateException: Invalid BundleContext.
>   at 
> org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:491)
>   at 
> org.apache.felix.framework.BundleContextImpl.ungetService(BundleContextImpl.java:455)
>   at 
> org.apache.sling.models.impl.injectors.OSGiServiceInjector$Callback.onDisposed(OSGiServiceInjector.java:203)
>  [org.apache.sling.models.impl:1.4.16]
>   at 
> org.apache.sling.models.impl.ModelAdapterFactory$DisposalCallbackRegistryImpl.onDisposed(ModelAdapterFactory.java:143)
>  [org.apache.sling.models.impl:1.4.16]
>   at 
> org.apache.sling.models.impl.ModelAdapterFactory.clearDisposalCallbackRegistryQueue(ModelAdapterFactory.java:214)
>  [org.apache.sling.models.impl:1.4.16]
>   at 
> org.apache.sling.models.impl.ModelAdapterFactory.run(ModelAdapterFactory.java:206)
>  [org.apache.sling.models.impl:1.4.16]
>   at 
> org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:349)
>  [org.apache.sling.commons.scheduler:2.7.12]
>   at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
> [org.apache.sling.commons.scheduler:2.7.12]
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
>   at java.lang.Thread.run(Unknown Source)
> {code}
> [0]: 
> https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L207



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[GitHub] [sling-org-apache-sling-models-impl] sagarmiglani commented on a change in pull request #34: SLING-11132 - Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread GitBox


sagarmiglani commented on a change in pull request #34:
URL: 
https://github.com/apache/sling-org-apache-sling-models-impl/pull/34#discussion_r803331667



##
File path: 
src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
##
@@ -204,7 +204,11 @@ public Callback(ServiceReference[] refs, BundleContext 
context) {
 public void onDisposed() {
 if (refs != null) {
 for (ServiceReference ref : refs) {
-context.ungetService(ref);
+try {
+context.ungetService(ref);
+} catch (IllegalStateException | IllegalArgumentException 
| NullPointerException exception) {

Review comment:
   Please let me know if I should replace multiple exception with a generic 
RuntimeException or this should be handled in a different way




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Created] (SLING-11132) Exception handling while clearing OSGiServiceReferences

2022-02-09 Thread Sagar Miglani (Jira)
Sagar Miglani created SLING-11132:
-

 Summary: Exception handling while clearing OSGiServiceReferences
 Key: SLING-11132
 URL: https://issues.apache.org/jira/browse/SLING-11132
 Project: Sling
  Issue Type: Improvement
  Components: Sling Models
Affects Versions: Models Implementation 1.5.0
Reporter: Sagar Miglani


*"Sling Models OSGi Service Disposal Job"* to clean the OSGi service references 
does not do any error handling.
If a ungetting of a reference [0] is failed due to some exception (like 
java.lang.IllegalStateException: Invalid BundleContext) no more references 
present in queue are cleaned up in same job trigger. The next reference in 
queue will be tried after 30 seconds (default) in next job trigger. Therefore, 
it may take an hour to clean up 120 references with an error.

To reproduce this:
 # Create a model consisting of OSGiService Injection
 # Use this model in a page
 # Open the created page and refresh it couple of time (10-15)
 # Restart the bundle with model created in step 1
 # One may see the following exceptions in the logs (after every ~30 seconds to 
clear up the OSGi service references)
{code:xml}
01.02.2021 14:31:03.639 *ERROR* [sling-default-1-Sling Models OSGi Service 
Disposal Job] org.apache.sling.commons.scheduler.impl.QuartzScheduler Exception 
during job execution of job 
'org.apache.sling.models.impl.ModelAdapterFactory@1b834b3c' with name 'Sling 
Models OSGi Service Disposal Job' : Invalid BundleContext.
java.lang.IllegalStateException: Invalid BundleContext.
at 
org.apache.felix.framework.BundleContextImpl.checkValidity(BundleContextImpl.java:491)
at 
org.apache.felix.framework.BundleContextImpl.ungetService(BundleContextImpl.java:455)
at 
org.apache.sling.models.impl.injectors.OSGiServiceInjector$Callback.onDisposed(OSGiServiceInjector.java:203)
 [org.apache.sling.models.impl:1.4.16]
at 
org.apache.sling.models.impl.ModelAdapterFactory$DisposalCallbackRegistryImpl.onDisposed(ModelAdapterFactory.java:143)
 [org.apache.sling.models.impl:1.4.16]
at 
org.apache.sling.models.impl.ModelAdapterFactory.clearDisposalCallbackRegistryQueue(ModelAdapterFactory.java:214)
 [org.apache.sling.models.impl:1.4.16]
at 
org.apache.sling.models.impl.ModelAdapterFactory.run(ModelAdapterFactory.java:206)
 [org.apache.sling.models.impl:1.4.16]
at 
org.apache.sling.commons.scheduler.impl.QuartzJobExecutor.execute(QuartzJobExecutor.java:349)
 [org.apache.sling.commons.scheduler:2.7.12]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) 
[org.apache.sling.commons.scheduler:2.7.12]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
{code}

[0]: 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/master/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L207



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


Re: [VOTE] Release Apache Sling Resource Resolver 1.8.4

2022-02-09 Thread Daniel Klco
+1

On Wed, Feb 9, 2022 at 5:48 AM Radu Cotescu  wrote:

> +1
>
> > On 9 Feb 2022, at 07:03, Carsten Ziegeler  wrote:
> >
> > Please vote to approve this release:
> >
> > [ ] +1 Approve the release
> > [ ] 0 Don't care
> > [ ] -1 Don't release, because ...
>
>


Re: [VOTE] Release Apache Sling Scripting Core 2.4.4

2022-02-09 Thread Daniel Klco
+1

On Wed, Feb 9, 2022 at 9:21 AM Carsten Ziegeler 
wrote:

> +1
>
> Carsten
>
> Am 09.02.2022 um 15:17 schrieb Radu Cotescu:
> > Hi,
> >
> > We solved 3 issues in this release:
> > https://issues.apache.org/jira/browse/SLING/fixforversion/12351310
> >
> > Staging repository:
> > https://repository.apache.org/content/repositories/orgapachesling-2598/
> >
> > You can use this UNIX script to download the release and verify the
> signatures:
> >
> https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD
> >
> > Usage:
> > sh check_staged_release.sh 2598 /tmp/sling-staging
> >
> > Please vote to approve this release:
> >
> >[ ] +1 Approve the release
> >[ ]  0 Don't care
> >[ ] -1 Don't release, because ...
> >
> > This majority vote is open for at least 72 hours.
> >
> > Regards,
> > Radu Cotescu
>
> --
> Carsten Ziegeler
> Adobe
> cziege...@apache.org
>


Re: [VOTE] Release Apache Sling Tenant 1.1.6

2022-02-09 Thread Daniel Klco
+1

On Wed, Feb 9, 2022 at 5:47 AM Radu Cotescu  wrote:

> +1
>
> > On 9 Feb 2022, at 07:01, Carsten Ziegeler  wrote:
> >
> > Please vote to approve this release:
> >
> > [ ] +1 Approve the release
> > [ ] 0 Don't care
> > [ ] -1 Don't release, because ...
>
>


Re: [VOTE] Release Apache Sling Testing Clients version 3.0.12

2022-02-09 Thread Daniel Klco
+1

On Wed, Feb 9, 2022 at 9:19 AM Radu Cotescu  wrote:

> +1
>
> > On 9 Feb 2022, at 14:47, Andrei Dulvac  wrote:
> >
> > Please vote to approve this release:
> >
> > [ ] +1 Approve the release
> > [ ] 0 Don't care
> > [ ] -1 Don't release, because ...
>
>


Re: [VOTE] Release Apache Sling Scripting Core 2.4.4

2022-02-09 Thread Carsten Ziegeler

+1

Carsten

Am 09.02.2022 um 15:17 schrieb Radu Cotescu:

Hi,

We solved 3 issues in this release:
https://issues.apache.org/jira/browse/SLING/fixforversion/12351310

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2598/

You can use this UNIX script to download the release and verify the signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2598 /tmp/sling-staging

Please vote to approve this release:

   [ ] +1 Approve the release
   [ ]  0 Don't care
   [ ] -1 Don't release, because ...

This majority vote is open for at least 72 hours.

Regards,
Radu Cotescu


--
Carsten Ziegeler
Adobe
cziege...@apache.org


Re: [VOTE] Release Apache Sling Testing Clients version 3.0.12

2022-02-09 Thread Radu Cotescu
+1

> On 9 Feb 2022, at 14:47, Andrei Dulvac  wrote:
> 
> Please vote to approve this release:
> 
> [ ] +1 Approve the release
> [ ] 0 Don't care
> [ ] -1 Don't release, because ...



[VOTE] Release Apache Sling Scripting Core 2.4.4

2022-02-09 Thread Radu Cotescu
Hi,

We solved 3 issues in this release:
https://issues.apache.org/jira/browse/SLING/fixforversion/12351310

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2598/

You can use this UNIX script to download the release and verify the signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2598 /tmp/sling-staging

Please vote to approve this release:

  [ ] +1 Approve the release
  [ ]  0 Don't care
  [ ] -1 Don't release, because ...

This majority vote is open for at least 72 hours.

Regards,
Radu Cotescu


Re: [VOTE] Release Apache Sling Testing Clients version 3.0.12

2022-02-09 Thread Carsten Ziegeler

+1

Carsten

Am 09.02.2022 um 14:47 schrieb Andrei Dulvac:

Hi,

It's me again... We resolved another ticket and we have to make another
release.

We solved 1 issues in this release:
https://issues.apache.org/jira/projects/SLING/versions/12351325

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2597

You can use this UNIX script to download the release and verify the
signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2597 /tmp/sling-staging

Please vote to approve this release:

   [ ] +1 Approve the release
   [ ]  0 Don't care
   [ ] -1 Don't release, because ...

This majority vote is open for at least 72 hours.



--
Carsten Ziegeler
Adobe
cziege...@apache.org


[VOTE] Release Apache Sling Testing Clients version 3.0.12

2022-02-09 Thread Andrei Dulvac
Hi,

It's me again... We resolved another ticket and we have to make another
release.

We solved 1 issues in this release:
https://issues.apache.org/jira/projects/SLING/versions/12351325

Staging repository:
https://repository.apache.org/content/repositories/orgapachesling-2597

You can use this UNIX script to download the release and verify the
signatures:
https://gitbox.apache.org/repos/asf?p=sling-tooling-release.git;a=blob;f=check_staged_release.sh;hb=HEAD

Usage:
sh check_staged_release.sh 2597 /tmp/sling-staging

Please vote to approve this release:

  [ ] +1 Approve the release
  [ ]  0 Don't care
  [ ] -1 Don't release, because ...

This majority vote is open for at least 72 hours.


[jira] [Resolved] (SLING-11131) Update Apache HTTP Client Dependency for CVE-2020-13956

2022-02-09 Thread Andrei Dulvac (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-11131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrei Dulvac resolved SLING-11131.
---
Resolution: Fixed

Fixed by 
https://github.com/apache/sling-org-apache-sling-testing-clients/commit/3e677d306d0ee7e807bcb3dc4c4b8634681f28ac
 

> Update Apache HTTP Client Dependency for CVE-2020-13956
> ---
>
> Key: SLING-11131
> URL: https://issues.apache.org/jira/browse/SLING-11131
> Project: Sling
>  Issue Type: Task
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.10
>Reporter: Andrei Tuicu
>Assignee: Andrei Dulvac
>Priority: Major
> Fix For: Apache Sling Testing Clients 3.0.12
>
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> org.apache.httpcomponents.httpclient 4.4.1 is vulnerable to 
> CVE-2020-13956(MEDIUM)[0].
> We need to update to the latest version of the Apache HTP Client 4.5.13. 
> [0] https://www.cvedetails.com/cve/CVE-2020-13956/



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Updated] (SLING-11131) Update Apache HTTP Client Dependency for CVE-2020-13956

2022-02-09 Thread Andrei Dulvac (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-11131?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andrei Dulvac updated SLING-11131:
--
Fix Version/s: Apache Sling Testing Clients 3.0.12

> Update Apache HTTP Client Dependency for CVE-2020-13956
> ---
>
> Key: SLING-11131
> URL: https://issues.apache.org/jira/browse/SLING-11131
> Project: Sling
>  Issue Type: Task
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.10
>Reporter: Andrei Tuicu
>Assignee: Andrei Dulvac
>Priority: Major
> Fix For: Apache Sling Testing Clients 3.0.12
>
>  Time Spent: 1h 10m
>  Remaining Estimate: 0h
>
> org.apache.httpcomponents.httpclient 4.4.1 is vulnerable to 
> CVE-2020-13956(MEDIUM)[0].
> We need to update to the latest version of the Apache HTP Client 4.5.13. 
> [0] https://www.cvedetails.com/cve/CVE-2020-13956/



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[RESULT] [VOTE] Release Apache Sling Testing Clients version 3.0.10

2022-02-09 Thread Andrei Dulvac
Hi, The vote has passed with the following result : +1 (binding): Carsten,
Robert, Radu, Daniel, Stefan +1 (non binding): none
-1: none
I will copy this release to the Sling dist directory and promote the
artifacts to the central Maven repository.

- Andrei


[jira] [Comment Edited] (SLING-11122) Improve logging when including Script Bindings

2022-02-09 Thread Joerg Hoh (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11122?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17487045#comment-17487045
 ] 

Joerg Hoh edited comment on SLING-11122 at 2/9/22, 1:06 PM:


PR: https://github.com/apache/sling-org-apache-sling-scripting-core/pull/12 
merged


was (Author: joerghoh):
PR: https://github.com/apache/sling-org-apache-sling-scripting-core/pull/12

> Improve logging when including Script Bindings
> --
>
> Key: SLING-11122
> URL: https://issues.apache.org/jira/browse/SLING-11122
> Project: Sling
>  Issue Type: Improvement
>  Components: Scripting
>Affects Versions: Scripting Core 2.4.2
>Reporter: Joerg Hoh
>Assignee: Joerg Hoh
>Priority: Major
> Fix For: Scripting Core 2.4.4
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Right now it is not possible to understand the overhead imposed by the 
> BindingsValuesProviders. 
> It should always be logged to the RequestProgressTracker how long it took to 
> add them all.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Resolved] (SLING-11122) Improve logging when including Script Bindings

2022-02-09 Thread Joerg Hoh (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-11122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joerg Hoh resolved SLING-11122.
---
Resolution: Fixed

> Improve logging when including Script Bindings
> --
>
> Key: SLING-11122
> URL: https://issues.apache.org/jira/browse/SLING-11122
> Project: Sling
>  Issue Type: Improvement
>  Components: Scripting
>Affects Versions: Scripting Core 2.4.2
>Reporter: Joerg Hoh
>Assignee: Joerg Hoh
>Priority: Major
> Fix For: Scripting Core 2.4.4
>
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> Right now it is not possible to understand the overhead imposed by the 
> BindingsValuesProviders. 
> It should always be logged to the RequestProgressTracker how long it took to 
> add them all.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[GitHub] [sling-org-apache-sling-scripting-core] joerghoh merged pull request #12: SLING-11122 log the time it took to add all bindings

2022-02-09 Thread GitBox


joerghoh merged pull request #12:
URL: https://github.com/apache/sling-org-apache-sling-scripting-core/pull/12


   


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Resolved] (SLING-11119) Optimise the service retrieval for bundled scripts

2022-02-09 Thread Radu Cotescu (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-9?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Radu Cotescu resolved SLING-9.
--
Resolution: Fixed

Implemented in [commit 
7a48301|https://github.com/apache/sling-org-apache-sling-scripting-core/commit/7a483015b17867b0bd8826f490cffa9211914ddf].

> Optimise the service retrieval for bundled scripts
> --
>
> Key: SLING-9
> URL: https://issues.apache.org/jira/browse/SLING-9
> Project: Sling
>  Issue Type: Improvement
>  Components: Scripting
>Reporter: Radu Cotescu
>Assignee: Radu Cotescu
>Priority: Major
> Fix For: Scripting Core 2.4.4
>
>  Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> The bundled scripts currently have an OSGi service cache per instance, 
> however in the 
> {{org.apache.sling.scripting.core.impl.bundled.ScriptContextProvider}} 
> there's already a service cache per bundle context which could be reused. 
> This would save significant memory in systems where there are a lot of 
> bundled scripts.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[GitHub] [sling-org-apache-sling-scripting-core] raducotescu merged pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu merged pull request #13:
URL: https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13


   


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[jira] [Closed] (SLING-11108) org.apache.sling.scripting.sightly.impl.engine.extension.FormatFilterExtensionTest#testDateFormatWithEscapedCharacters fails on newer JDKs

2022-02-09 Thread Radu Cotescu (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-11108?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Radu Cotescu closed SLING-11108.


> org.apache.sling.scripting.sightly.impl.engine.extension.FormatFilterExtensionTest#testDateFormatWithEscapedCharacters
>  fails on newer JDKs
> --
>
> Key: SLING-11108
> URL: https://issues.apache.org/jira/browse/SLING-11108
> Project: Sling
>  Issue Type: Bug
>  Components: Scripting
>Affects Versions: Scripting HTL Engine 1.4.14-1.4.0
>Reporter: Radu Cotescu
>Assignee: Radu Cotescu
>Priority: Major
> Fix For: Scripting HTL Engine 1.4.16-1.4.0
>
>
> {{org.apache.sling.scripting.sightly.impl.engine.extension.FormatFilterExtensionTest#testDateFormatWithEscapedCharacters}}
>  doesn't provide a locale, allowing the JDK to select one based on its own 
> logic. However, this make the test unstable on different JDK versions, 
> depending on which locale is enabled on the running system.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Closed] (SLING-11105) Make the SlingHTLMasterCompiler a dynamic reference in the SightlyScriptEngineFactory

2022-02-09 Thread Radu Cotescu (Jira)


 [ 
https://issues.apache.org/jira/browse/SLING-11105?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Radu Cotescu closed SLING-11105.


> Make the SlingHTLMasterCompiler a dynamic reference in the 
> SightlyScriptEngineFactory
> -
>
> Key: SLING-11105
> URL: https://issues.apache.org/jira/browse/SLING-11105
> Project: Sling
>  Issue Type: Improvement
>  Components: Scripting
>Reporter: Radu Cotescu
>Assignee: Radu Cotescu
>Priority: Major
> Fix For: Scripting HTL Engine 1.4.16-1.4.0
>
>
> Since the {{SlingHTLMasterCompiler}} is already an optional dependency, it 
> makes sense to set its policy to dynamic, in order to optimise the activation 
> process of the {{SightlyScriptEngineFactory}} when deployed on instances 
> where the scripts are precompiled.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[jira] [Commented] (SLING-11129) FSClassLoader shows Copyright of Adobe

2022-02-09 Thread Robert Munteanu (Jira)


[ 
https://issues.apache.org/jira/browse/SLING-11129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17489508#comment-17489508
 ] 

Robert Munteanu commented on SLING-11129:
-

Thanks [~dklco]!

> FSClassLoader shows Copyright of Adobe
> --
>
> Key: SLING-11129
> URL: https://issues.apache.org/jira/browse/SLING-11129
> Project: Sling
>  Issue Type: Improvement
>  Components: Commons
>Affects Versions: File System ClassLoader 1.0.14
>Reporter: Joerg Hoh
>Priority: Major
>
> The FSClassLoaderMBean java file still shows copyright by Adobe and also 
> refers to "ACS AEM Commons Bundle":
> https://github.com/apache/sling-org-apache-sling-commons-fsclassloader/blob/f60524e668a8e31c0697df418c2aef8b519c30f9/src/main/java/org/apache/sling/commons/fsclassloader/FSClassLoaderMBean.java#L5



--
This message was sent by Atlassian Jira
(v8.20.1#820001)


[RESULT] [VOTE] Release Apache Sling Scripting HTL Engine 1.4.16-1.4.0

2022-02-09 Thread Radu Cotescu
Hi,

The vote has passed with the following result:

+1 (binding): Radu Cotescu, Eric Norman, Robert Munteanu
+1 (non-binding): none

I will copy this release to the Sling dist directory and
promote the artifacts to the central Maven repository.

Regards,
Radu Cotescu


[GitHub] [sling-org-apache-sling-scripting-core] sonarcloud[bot] removed a comment on pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


sonarcloud[bot] removed a comment on pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#issuecomment-1032887422


   SonarCloud Quality Gate failed.  ![Quality Gate 
failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png
 'Quality Gate failed')
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
 [6 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
   
   
[![65.8%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'65.8%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_coverage=list)
 [65.8% 
Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_duplicated_lines_density=list)
   
   


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-scripting-core] sonarcloud[bot] commented on pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


sonarcloud[bot] commented on pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#issuecomment-1033624519


   SonarCloud Quality Gate failed.  ![Quality Gate 
failed](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/QualityGateBadge/failed-16px.png
 'Quality Gate failed')
   
   
[![Bug](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/bug-16px.png
 
'Bug')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
 [0 
Bugs](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=BUG)
  
   
[![Vulnerability](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/vulnerability-16px.png
 
'Vulnerability')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
 [0 
Vulnerabilities](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=VULNERABILITY)
  
   [![Security 
Hotspot](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/security_hotspot-16px.png
 'Security 
Hotspot')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
 [0 Security 
Hotspots](https://sonarcloud.io/project/security_hotspots?id=apache_sling-org-apache-sling-scripting-core=13=false=SECURITY_HOTSPOT)
  
   [![Code 
Smell](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/common/code_smell-16px.png
 'Code 
Smell')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
 
[![A](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/RatingBadge/A-16px.png
 
'A')](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
 [6 Code 
Smells](https://sonarcloud.io/project/issues?id=apache_sling-org-apache-sling-scripting-core=13=false=CODE_SMELL)
   
   
[![67.1%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/CoverageChart/60-16px.png
 
'67.1%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_coverage=list)
 [67.1% 
Coverage](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_coverage=list)
  
   
[![0.0%](https://sonarsource.github.io/sonarcloud-github-static-resources/v2/checks/Duplications/3-16px.png
 
'0.0%')](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_duplicated_lines_density=list)
 [0.0% 
Duplication](https://sonarcloud.io/component_measures?id=apache_sling-org-apache-sling-scripting-core=13=new_duplicated_lines_density=list)
   
   


-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




Re: [VOTE] Release Apache Sling Resource Resolver 1.8.4

2022-02-09 Thread Radu Cotescu
+1

> On 9 Feb 2022, at 07:03, Carsten Ziegeler  wrote:
> 
> Please vote to approve this release:
> 
> [ ] +1 Approve the release
> [ ] 0 Don't care
> [ ] -1 Don't release, because ...



Re: [VOTE] Release Apache Sling Tenant 1.1.6

2022-02-09 Thread Radu Cotescu
+1

> On 9 Feb 2022, at 07:01, Carsten Ziegeler  wrote:
> 
> Please vote to approve this release:
> 
> [ ] +1 Approve the release
> [ ] 0 Don't care
> [ ] -1 Don't release, because ...



Re: [Scripting] Bindings returning null

2022-02-09 Thread Radu Cotescu
Hi Jörg,

> On 4 Feb 2022, at 12:00, Jörg Hoh  wrote:
> 
> In my opinion we should adjust these BindingsValuesProviders and require
> the consumers of these bindings to make sure that they do the null-check as
> required by the spec.

What do you specifically mean by adjusting the BVPs? Do you have a small 
example?

Thanks,
Radu

[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802523466



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);
+Collections.sort(localFilteredReferences);
+// get the highest ranking first
+Collections.reverse(localFilteredReferences);
+for (ServiceReference serviceReference : 
localFilteredReferences) {
+Reference lookup = new Reference(serviceReference);
+if (cachedReferences.contains(lookup)) {
+for (Reference reference : cachedReferences) {
+if 
(serviceReference.equals(reference.getServiceReference())) {
+ServiceType service = (ServiceType) 
reference.getService();
+if (service != null) {
+result.add(service);
+}
+break;
+}
+}
+} else {
+// concurrent change; restart
+return getServices(type, filter);
+}
 }
 }
-
-// unget the service if another thread was faster
-if (ref != null) {
-this.bundleContext.ungetService(ref);
-}
+} catch (InvalidSyntaxException e) {
+LOGGER.error(String.format("Unable to retrieve the services of 
type %s.", type.getName()), e);
 }
-
-// return whatever we got (which may be null)
-return (ServiceType) reference.service;
+if (!result.isEmpty()) {
+ServiceType[] srv = (ServiceType[]) Array.newInstance(type, 
result.size());
+return result.toArray(srv);
+}
+return null;
 }
 
 /**
  * @see 
org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
  */
 public void serviceChanged(ServiceEvent event) {
-final String[] objectClasses = 
(String[])event.getServiceReference().getProperty(Constants.OBJECTCLASS);
-if ( objectClasses != null) {
-for(final String key : objectClasses) {
-Reference ref = null;
-synchronized ( this ) {
-ref = this.cache.remove(key);
+ServiceReference serviceReference = event.getServiceReference();
+final String[] objectClasses = (String[]) 
serviceReference.getProperty(Constants.OBJECTCLASS);
+if (objectClasses != null) {
+for (final String key : objectClasses) {
+SortedSet references;
+synchronized (this) {
+  

[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802516365



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);

Review comment:
   We do need this list, as we need to sort the `ServiceReferences` 
according to their ranking, in order to be able to return the array with the 
`ServiceTypes`, the latter being objects that don't implement `Comparable`.




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802463407



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);
+Collections.sort(localFilteredReferences);
+// get the highest ranking first
+Collections.reverse(localFilteredReferences);
+for (ServiceReference serviceReference : 
localFilteredReferences) {
+Reference lookup = new Reference(serviceReference);
+if (cachedReferences.contains(lookup)) {
+for (Reference reference : cachedReferences) {
+if 
(serviceReference.equals(reference.getServiceReference())) {
+ServiceType service = (ServiceType) 
reference.getService();
+if (service != null) {
+result.add(service);
+}
+break;
+}
+}
+} else {
+// concurrent change; restart
+return getServices(type, filter);
+}
 }
 }
-
-// unget the service if another thread was faster
-if (ref != null) {
-this.bundleContext.ungetService(ref);
-}
+} catch (InvalidSyntaxException e) {
+LOGGER.error(String.format("Unable to retrieve the services of 
type %s.", type.getName()), e);
 }
-
-// return whatever we got (which may be null)
-return (ServiceType) reference.service;
+if (!result.isEmpty()) {
+ServiceType[] srv = (ServiceType[]) Array.newInstance(type, 
result.size());
+return result.toArray(srv);
+}
+return null;
 }
 
 /**
  * @see 
org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
  */
 public void serviceChanged(ServiceEvent event) {
-final String[] objectClasses = 
(String[])event.getServiceReference().getProperty(Constants.OBJECTCLASS);
-if ( objectClasses != null) {
-for(final String key : objectClasses) {
-Reference ref = null;
-synchronized ( this ) {
-ref = this.cache.remove(key);
+ServiceReference serviceReference = event.getServiceReference();
+final String[] objectClasses = (String[]) 
serviceReference.getProperty(Constants.OBJECTCLASS);
+if (objectClasses != null) {
+for (final String key : objectClasses) {
+SortedSet references;
+synchronized (this) {
+  

[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802461699



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);
+Collections.sort(localFilteredReferences);
+// get the highest ranking first
+Collections.reverse(localFilteredReferences);
+for (ServiceReference serviceReference : 
localFilteredReferences) {
+Reference lookup = new Reference(serviceReference);
+if (cachedReferences.contains(lookup)) {
+for (Reference reference : cachedReferences) {
+if 
(serviceReference.equals(reference.getServiceReference())) {
+ServiceType service = (ServiceType) 
reference.getService();
+if (service != null) {
+result.add(service);
+}
+break;
+}
+}
+} else {
+// concurrent change; restart
+return getServices(type, filter);
+}
 }
 }
-
-// unget the service if another thread was faster
-if (ref != null) {
-this.bundleContext.ungetService(ref);
-}
+} catch (InvalidSyntaxException e) {
+LOGGER.error(String.format("Unable to retrieve the services of 
type %s.", type.getName()), e);
 }
-
-// return whatever we got (which may be null)
-return (ServiceType) reference.service;
+if (!result.isEmpty()) {
+ServiceType[] srv = (ServiceType[]) Array.newInstance(type, 
result.size());
+return result.toArray(srv);
+}
+return null;
 }
 
 /**
  * @see 
org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
  */
 public void serviceChanged(ServiceEvent event) {
-final String[] objectClasses = 
(String[])event.getServiceReference().getProperty(Constants.OBJECTCLASS);
-if ( objectClasses != null) {
-for(final String key : objectClasses) {
-Reference ref = null;
-synchronized ( this ) {
-ref = this.cache.remove(key);
+ServiceReference serviceReference = event.getServiceReference();
+final String[] objectClasses = (String[]) 
serviceReference.getProperty(Constants.OBJECTCLASS);
+if (objectClasses != null) {
+for (final String key : objectClasses) {
+SortedSet references;
+synchronized (this) {
+  

[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802461161



##
File path: 
src/main/java/org/apache/sling/scripting/core/impl/bundled/AbstractBundledRenderUnit.java
##
@@ -101,83 +95,37 @@ public BundleContext getBundleContext() {
 return scriptExtension;
 }
 
+@Override
+public @NotNull ServiceCache getServiceCache() {
+return serviceCache;
+}
+
 @Override
 @Nullable
 @SuppressWarnings("unchecked")
 public  T getService(@NotNull String className) {
-LOG.debug("Attempting to load class {} as an OSGi service.", 
className);
-T result = (this.services == null ? null : (T) 
this.services.get(className));
-if (result == null) {
-final ServiceReference ref = 
this.bundleContext.getServiceReference(className);
-if (ref != null) {
-result = (T) this.bundleContext.getService(ref);
-if (result != null) {
-if (this.services == null) {
-this.services = new HashMap<>();
-}
-if (this.references == null) {
-this.references = new ArrayList<>();
-}
-this.references.add(ref);
-this.services.put(className, result);
-return result;
-}
-}
+try {
+ClassLoader bundleClassloader = 
getBundle().adapt(BundleWiring.class).getClassLoader();
+return (T) 
serviceCache.getService(bundleClassloader.loadClass(className));
+} catch (ClassNotFoundException e) {
+LOG.error("Unable to retrieve a service of type " + className + " 
for bundled script " + path, e);
 }
-return result;
+return null;
 }
 
 @Override
 @Nullable
 @SuppressWarnings("unchecked")
 public  T[] getServices(@NotNull String className, @Nullable String 
filter) {
-T[] result = null;
 try {
-final ServiceReference[] refs = 
this.bundleContext.getServiceReferences(className, filter);
-
-if (refs != null) {
-// sort by service ranking (lowest first) (see 
ServiceReference#compareTo(Object))
-List> localReferences = 
Arrays.asList(refs);
-Collections.sort(localReferences);
-// get the highest ranking first
-Collections.reverse(localReferences);
-
-final List objects = new ArrayList<>();
-for (ServiceReference reference : localReferences) {
-final T service = (T) 
this.bundleContext.getService(reference);
-if (service != null) {
-if (this.references == null) {
-this.references = new ArrayList<>();
-}
-this.references.add(reference);
-objects.add(service);
-}
-}
-if (!objects.isEmpty()) {
-T[] srv = (T[]) 
Array.newInstance(bundle.loadClass(className), objects.size());
-result = objects.toArray(srv);
-}
-}
-} catch (Exception e) {
-LOG.error(String.format("Unable to retrieve the services of type 
%s.", className), e);
+ClassLoader bundleClassloader = 
getBundle().adapt(BundleWiring.class).getClassLoader();
+return (T[]) 
serviceCache.getServices(bundleClassloader.loadClass(className), filter);
+} catch (ClassNotFoundException e) {

Review comment:
   Same as above.




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-scripting-core] raducotescu commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


raducotescu commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802461016



##
File path: 
src/main/java/org/apache/sling/scripting/core/impl/bundled/AbstractBundledRenderUnit.java
##
@@ -101,83 +95,37 @@ public BundleContext getBundleContext() {
 return scriptExtension;
 }
 
+@Override
+public @NotNull ServiceCache getServiceCache() {
+return serviceCache;
+}
+
 @Override
 @Nullable
 @SuppressWarnings("unchecked")
 public  T getService(@NotNull String className) {
-LOG.debug("Attempting to load class {} as an OSGi service.", 
className);
-T result = (this.services == null ? null : (T) 
this.services.get(className));
-if (result == null) {
-final ServiceReference ref = 
this.bundleContext.getServiceReference(className);
-if (ref != null) {
-result = (T) this.bundleContext.getService(ref);
-if (result != null) {
-if (this.services == null) {
-this.services = new HashMap<>();
-}
-if (this.references == null) {
-this.references = new ArrayList<>();
-}
-this.references.add(ref);
-this.services.put(className, result);
-return result;
-}
-}
+try {
+ClassLoader bundleClassloader = 
getBundle().adapt(BundleWiring.class).getClassLoader();
+return (T) 
serviceCache.getService(bundleClassloader.loadClass(className));
+} catch (ClassNotFoundException e) {

Review comment:
   In HTL we always made sure that the object to load was accessible to the 
classloader with which the script was loaded. This was not necessarily the case 
for JSPs, but for bundled scripts they worked like that from the beginning - 
see 
https://github.com/apache/sling-org-apache-sling-scripting-spi/blob/47949fedc62380822961d8ef649130dee68a28e8/src/main/java/org/apache/sling/scripting/spi/bundle/BundledRenderUnit.java#L83.




-- 
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: dev-unsubscr...@sling.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [sling-org-apache-sling-scripting-core] jsedding commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


jsedding commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802417180



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);
+Collections.sort(localFilteredReferences);
+// get the highest ranking first
+Collections.reverse(localFilteredReferences);
+for (ServiceReference serviceReference : 
localFilteredReferences) {
+Reference lookup = new Reference(serviceReference);
+if (cachedReferences.contains(lookup)) {
+for (Reference reference : cachedReferences) {
+if 
(serviceReference.equals(reference.getServiceReference())) {
+ServiceType service = (ServiceType) 
reference.getService();
+if (service != null) {
+result.add(service);
+}
+break;
+}
+}
+} else {
+// concurrent change; restart
+return getServices(type, filter);
+}
 }
 }
-
-// unget the service if another thread was faster
-if (ref != null) {
-this.bundleContext.ungetService(ref);
-}
+} catch (InvalidSyntaxException e) {
+LOGGER.error(String.format("Unable to retrieve the services of 
type %s.", type.getName()), e);
 }
-
-// return whatever we got (which may be null)
-return (ServiceType) reference.service;
+if (!result.isEmpty()) {
+ServiceType[] srv = (ServiceType[]) Array.newInstance(type, 
result.size());
+return result.toArray(srv);
+}
+return null;
 }
 
 /**
  * @see 
org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
  */
 public void serviceChanged(ServiceEvent event) {
-final String[] objectClasses = 
(String[])event.getServiceReference().getProperty(Constants.OBJECTCLASS);
-if ( objectClasses != null) {
-for(final String key : objectClasses) {
-Reference ref = null;
-synchronized ( this ) {
-ref = this.cache.remove(key);
+ServiceReference serviceReference = event.getServiceReference();
+final String[] objectClasses = (String[]) 
serviceReference.getProperty(Constants.OBJECTCLASS);
+if (objectClasses != null) {
+for (final String key : objectClasses) {
+SortedSet references;
+synchronized (this) {
+ 

[GitHub] [sling-org-apache-sling-scripting-core] jsedding commented on a change in pull request #13: SLING-11119 - Optimise the service retrieval for bundled scripts

2022-02-09 Thread GitBox


jsedding commented on a change in pull request #13:
URL: 
https://github.com/apache/sling-org-apache-sling-scripting-core/pull/13#discussion_r802416993



##
File path: src/main/java/org/apache/sling/scripting/core/impl/ServiceCache.java
##
@@ -63,70 +70,151 @@ public void dispose() {
  * @return The service or null
  */
 @SuppressWarnings("unchecked")
+@Nullable
 public  ServiceType getService(Class type) {
-final String key = type.getName();
-Reference reference = this.cache.get(key);
-if (reference == null) {
-
-// get the service
-ServiceReference ref = this.bundleContext.getServiceReference(key);
-if (ref != null) {
-final Object service = this.bundleContext.getService(ref);
-if (service != null) {
-reference = new Reference();
-reference.service = service;
-reference.reference = ref;
-} else {
-ref = null;
-}
-}
-
-// assume missing service
-if (reference == null) {
-reference = NULL_REFERENCE;
+SortedSet references = getCachedReferences(type);
+for (Reference reference : references) {
+ServiceType service = (ServiceType) reference.getService();
+if (service != null) {
+return service;
 }
+}
+return null;
+}
 
-// check to see whether another thread has not done the same thing
-synchronized (this) {
-Reference existing = this.cache.get(key);
-if (existing == null) {
-this.cache.put(key, reference);
-ref = null;
-} else {
-reference = existing;
+@SuppressWarnings("unchecked")
+@Nullable
+public  ServiceType[] getServices(Class type, 
String filter) {
+List result = new ArrayList<>();
+try {
+SortedSet cachedReferences = getCachedReferences(type);
+final Collection> filteredReferences 
= this.bundleContext.getServiceReferences(type, filter);
+if (!filteredReferences.isEmpty()) {
+List> localFilteredReferences = 
new ArrayList<>(filteredReferences);
+Collections.sort(localFilteredReferences);
+// get the highest ranking first
+Collections.reverse(localFilteredReferences);
+for (ServiceReference serviceReference : 
localFilteredReferences) {
+Reference lookup = new Reference(serviceReference);
+if (cachedReferences.contains(lookup)) {
+for (Reference reference : cachedReferences) {
+if 
(serviceReference.equals(reference.getServiceReference())) {
+ServiceType service = (ServiceType) 
reference.getService();
+if (service != null) {
+result.add(service);
+}
+break;
+}
+}
+} else {
+// concurrent change; restart
+return getServices(type, filter);
+}
 }
 }
-
-// unget the service if another thread was faster
-if (ref != null) {
-this.bundleContext.ungetService(ref);
-}
+} catch (InvalidSyntaxException e) {
+LOGGER.error(String.format("Unable to retrieve the services of 
type %s.", type.getName()), e);
 }
-
-// return whatever we got (which may be null)
-return (ServiceType) reference.service;
+if (!result.isEmpty()) {
+ServiceType[] srv = (ServiceType[]) Array.newInstance(type, 
result.size());
+return result.toArray(srv);
+}
+return null;
 }
 
 /**
  * @see 
org.osgi.framework.ServiceListener#serviceChanged(org.osgi.framework.ServiceEvent)
  */
 public void serviceChanged(ServiceEvent event) {
-final String[] objectClasses = 
(String[])event.getServiceReference().getProperty(Constants.OBJECTCLASS);
-if ( objectClasses != null) {
-for(final String key : objectClasses) {
-Reference ref = null;
-synchronized ( this ) {
-ref = this.cache.remove(key);
+ServiceReference serviceReference = event.getServiceReference();
+final String[] objectClasses = (String[]) 
serviceReference.getProperty(Constants.OBJECTCLASS);
+if (objectClasses != null) {
+for (final String key : objectClasses) {
+SortedSet references;
+synchronized (this) {
+ 

Re: [VOTE] Release Apache Sling Resource Resolver 1.8.4

2022-02-09 Thread Robert Munteanu
On Wed, 2022-02-09 at 07:03 +0100, Carsten Ziegeler wrote:
> Please vote to approve this release:

+1
Robert


signature.asc
Description: This is a digitally signed message part


Re: [VOTE] Release Apache Sling Tenant 1.1.6

2022-02-09 Thread Robert Munteanu
On Wed, 2022-02-09 at 07:01 +0100, Carsten Ziegeler wrote:
> Please vote to approve this release:

+1
Robert


signature.asc
Description: This is a digitally signed message part


RE: [VOTE] Release Apache Sling Resource Resolver 1.8.4

2022-02-09 Thread Stefan Seifert
+1 


RE: [VOTE] Release Apache Sling Tenant 1.1.6

2022-02-09 Thread Stefan Seifert
+1 


RE: [VOTE] Release Apache Sling Testing Clients version 3.0.10

2022-02-09 Thread Stefan Seifert
+1