[jira] [Commented] (SLING-12241) Anonymous sling testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-12241:


Good catch, [~rombert], fixed the title/description.

> Anonymous sling testing client throws NPE
> -
>
> Key: SLING-12241
> URL: https://issues.apache.org/jira/browse/SLING-12241
> Project: Sling
>  Issue Type: Bug
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.22
>Reporter: Evgeny Tugarev
>Assignee: Andrei Dulvac
>Priority: Major
>
> When _null_ is passed as a user name to sling testing client, to mimic the 
> anonymous user, an NPE is thrown in FormBasedAuthInterceptor.
> to reproduce:
> {code:java}
> FormBasedAuthInterceptor interceptor = new 
> FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
> SlingClient anonymousClient = SlingClient.Builder.create(httpServer.getURI(), 
> null, "pass")
> .addInterceptorLast(interceptor).build();
> annonnymousClient.doGet(LOGIN_OK_PATH, 200); // NPE
> {code}
>  



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


[jira] [Updated] (SLING-12241) Anonymous testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev updated SLING-12241:
---
Description: 
When _null_ is passed as a user name to sling testing client, to mimic the 
anonymous user, an NPE is thrown in FormBasedAuthInterceptor.

to reproduce:
{code:java}
FormBasedAuthInterceptor interceptor = new 
FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
SlingClient anonymousClient = SlingClient.Builder.create(httpServer.getURI(), 
null, "pass")
.addInterceptorLast(interceptor).build();

annonnymousClient.doGet(LOGIN_OK_PATH, 200); // NPE
{code}
 

  was:
When _null_ is passed as a user name to sling testing client, to mimic the 
anonymous user, an NPE is thrown in FormBasedAuthInterceptor.

to reproduce:
{code:java}
FormBasedAuthInterceptor interceptor = new 
FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
"pass")
.addInterceptorLast(interceptor).build();

client.doGet(LOGIN_OK_PATH, 200); // NPE
{code}
 


> Anonymous testing client throws NPE
> ---
>
> Key: SLING-12241
> URL: https://issues.apache.org/jira/browse/SLING-12241
> Project: Sling
>  Issue Type: Bug
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.22
>Reporter: Evgeny Tugarev
>Assignee: Andrei Dulvac
>Priority: Major
>
> When _null_ is passed as a user name to sling testing client, to mimic the 
> anonymous user, an NPE is thrown in FormBasedAuthInterceptor.
> to reproduce:
> {code:java}
> FormBasedAuthInterceptor interceptor = new 
> FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
> SlingClient anonymousClient = SlingClient.Builder.create(httpServer.getURI(), 
> null, "pass")
> .addInterceptorLast(interceptor).build();
> annonnymousClient.doGet(LOGIN_OK_PATH, 200); // NPE
> {code}
>  



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


[jira] [Updated] (SLING-12241) Anonymous sling testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev updated SLING-12241:
---
Summary: Anonymous sling testing client throws NPE  (was: Anonymous testing 
client throws NPE)

> Anonymous sling testing client throws NPE
> -
>
> Key: SLING-12241
> URL: https://issues.apache.org/jira/browse/SLING-12241
> Project: Sling
>  Issue Type: Bug
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.22
>Reporter: Evgeny Tugarev
>Assignee: Andrei Dulvac
>Priority: Major
>
> When _null_ is passed as a user name to sling testing client, to mimic the 
> anonymous user, an NPE is thrown in FormBasedAuthInterceptor.
> to reproduce:
> {code:java}
> FormBasedAuthInterceptor interceptor = new 
> FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
> SlingClient anonymousClient = SlingClient.Builder.create(httpServer.getURI(), 
> null, "pass")
> .addInterceptorLast(interceptor).build();
> annonnymousClient.doGet(LOGIN_OK_PATH, 200); // NPE
> {code}
>  



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


[jira] [Updated] (SLING-12241) Anonymous testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev updated SLING-12241:
---
Description: 
When null is passed as a user name to sling testing client, to mimic the 
anonymous user, an NPE is thrown in FormBasedAuthInterceptor.

to reproduce:
{code:java}
FormBasedAuthInterceptor interceptor = new 
FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
"pass")
.addInterceptorLast(interceptor).build();

client.doGet(LOGIN_OK_PATH, 200); // NPE
{code}
 

  was:
When using the AEM testing Clients: anonymous client to access content on a 
publish instance ( AEMCS)  the client throws an NPE

to reproduce:
{code:java}
 anonymousPublish = cqBaseClassRule.publishRule.getClient(CQClient.class, null, 
null);
 anonymousPublish.doGet("/graphql/execute.json", 204);
{code}
 


> Anonymous testing client throws NPE
> ---
>
> Key: SLING-12241
> URL: https://issues.apache.org/jira/browse/SLING-12241
> Project: Sling
>  Issue Type: Bug
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.22
>Reporter: Evgeny Tugarev
>Assignee: Andrei Dulvac
>Priority: Major
>
> When null is passed as a user name to sling testing client, to mimic the 
> anonymous user, an NPE is thrown in FormBasedAuthInterceptor.
> to reproduce:
> {code:java}
> FormBasedAuthInterceptor interceptor = new 
> FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
> SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
> "pass")
> .addInterceptorLast(interceptor).build();
> client.doGet(LOGIN_OK_PATH, 200); // NPE
> {code}
>  



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


[jira] [Updated] (SLING-12241) Anonymous testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev updated SLING-12241:
---
Description: 
When _null_ is passed as a user name to sling testing client, to mimic the 
anonymous user, an NPE is thrown in FormBasedAuthInterceptor.

to reproduce:
{code:java}
FormBasedAuthInterceptor interceptor = new 
FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
"pass")
.addInterceptorLast(interceptor).build();

client.doGet(LOGIN_OK_PATH, 200); // NPE
{code}
 

  was:
When null is passed as a user name to sling testing client, to mimic the 
anonymous user, an NPE is thrown in FormBasedAuthInterceptor.

to reproduce:
{code:java}
FormBasedAuthInterceptor interceptor = new 
FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
"pass")
.addInterceptorLast(interceptor).build();

client.doGet(LOGIN_OK_PATH, 200); // NPE
{code}
 


> Anonymous testing client throws NPE
> ---
>
> Key: SLING-12241
> URL: https://issues.apache.org/jira/browse/SLING-12241
> Project: Sling
>  Issue Type: Bug
>  Components: Apache Sling Testing Clients
>Affects Versions: Apache Sling Testing Clients 3.0.22
>Reporter: Evgeny Tugarev
>Assignee: Andrei Dulvac
>Priority: Major
>
> When _null_ is passed as a user name to sling testing client, to mimic the 
> anonymous user, an NPE is thrown in FormBasedAuthInterceptor.
> to reproduce:
> {code:java}
> FormBasedAuthInterceptor interceptor = new 
> FormBasedAuthInterceptor(LOGIN_COOKIE_NAME); 
> SlingClient client = SlingClient.Builder.create(httpServer.getURI(), null, 
> "pass")
> .addInterceptorLast(interceptor).build();
> client.doGet(LOGIN_OK_PATH, 200); // NPE
> {code}
>  



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


[jira] [Created] (SLING-12241) Anonymous testing client throws NPE

2024-02-02 Thread Evgeny Tugarev (Jira)
Evgeny Tugarev created SLING-12241:
--

 Summary: Anonymous testing client throws NPE
 Key: SLING-12241
 URL: https://issues.apache.org/jira/browse/SLING-12241
 Project: Sling
  Issue Type: Bug
  Components: Apache Sling Testing Clients
Affects Versions: Apache Sling Testing Clients 3.0.22
Reporter: Evgeny Tugarev


When using the AEM testing Clients: anonymous client to access content on a 
publish instance ( AEMCS)  the client throws an NPE

to reproduce:
{code:java}
 anonymousPublish = cqBaseClassRule.publishRule.getClient(CQClient.class, null, 
null);
 anonymousPublish.doGet("/graphql/execute.json", 204);
{code}
 



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


[jira] [Created] (SLING-9626) JsonWriter auto closes the output stream

2020-08-04 Thread Evgeny Tugarev (Jira)
Evgeny Tugarev created SLING-9626:
-

 Summary: JsonWriter auto closes the output stream
 Key: SLING-9626
 URL: https://issues.apache.org/jira/browse/SLING-9626
 Project: Sling
  Issue Type: Bug
  Components: GraphQL
Affects Versions: GraphQL Core 0.0.4
Reporter: Evgeny Tugarev


Current implementation closes the output stream which produces an error 
org.apache.sling.engine.impl.SlingRequestProcessorImpl Writer has already been 
closed.
org.apache.sling.engine.impl.SlingHttpServletResponseImpl$WriterAlreadyClosedException:
 null
at 
org.apache.sling.engine.impl.SlingHttpServletResponseImpl$1.checkClosed(SlingHttpServletResponseImpl.java:190)
[https://github.com/apache/sling-org-apache-sling-graphql-core/blob/b22657e5cc435332cec7c60ad30692d2190caff8/src/main/java/org/apache/sling/graphql/core/json/JsonSerializer.java#L53]



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (SLING-8706) Injections for java.util.Optional<> should be automatic optional

2019-11-24 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-8706:
---

[~joerghoh] I made a progress with the implementation, please have a 
look/comment.

> Injections for java.util.Optional<> should be automatic optional 
> -
>
> Key: SLING-8706
> URL: https://issues.apache.org/jira/browse/SLING-8706
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Reporter: Jörg Hoh
>Priority: Major
>  Time Spent: 2h 10m
>  Remaining Estimate: 0h
>
> The current approach to support optional injections requires to annotate the 
> field with {{@Optional}} plus proper handling within the javacode (null 
> checks etc), which can be forgotten.
> So instead of
> {code}
> @Inject @Optional
> String fieldname;
> {code}
> it should also be possible to use this
> {code}
> @Inject
> Optional fieldname;
> {code}
> with the very same semantic. But the developer is forced to deal with the 
> case that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (SLING-8858) Model Cache causes NPE in sling.models.impl 1.4.10+

2019-11-22 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev edited comment on SLING-8858 at 11/22/19 10:54 PM:
--

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


was (Author: etugarev):
PR filled:[https://github.com/apache/sling-org-apache-sling-models-impl/pull/18]

> Model Cache causes NPE in sling.models.impl 1.4.10+
> ---
>
> Key: SLING-8858
> URL: https://issues.apache.org/jira/browse/SLING-8858
> Project: Sling
>  Issue Type: Bug
>  Components: Sling Models
>Affects Versions: Sling Models Impl 1.4.10
> Environment: Java SE 1.8.0_231
>Reporter: Frank Pauleickhoff
>Priority: Major
>
> In AEM 6.4 ServicePack 6 we face NullPointerExceptions when using the Sling 
> model cache that used to work before (in SP 3).
> *Exception Stacktrace is:*
> {code:java}
> 22.11.2019 15:29:22.525 *ERROR* [127.0.0.1 [1574432957337] GET 
> /content/mypage.html HTTP/1.1] 
> org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught 
> SlingException
> org.apache.sling.scripting.sightly.SightlyException: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> Identifier xx.xxx.MyModel cannot be correctly instantiated by the Use API
> [...]
> Caused by: java.lang.NullPointerException: null
>  at 
> org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:407)
>  at 
> org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:314)
> {code}
> Problem seems to be related to introduction of WeakReferences in SLING-7586. 
> Without knowing any details and being deeply into the Sling Model Caching 
> implementation, I think a null-check is missing for "SoftReference" in Line 
> 407:
> {code:java}
> SoftReference SoftReference = adaptableCache.get(requestedType);
> ModelType cachedObject = (ModelType) SoftReference.get();
> {code}
> That seems to cause caching to throw NPE for any not yet cached model.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (SLING-8858) Model Cache causes NPE in sling.models.impl 1.4.10+

2019-11-22 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-8858:
---

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

> Model Cache causes NPE in sling.models.impl 1.4.10+
> ---
>
> Key: SLING-8858
> URL: https://issues.apache.org/jira/browse/SLING-8858
> Project: Sling
>  Issue Type: Bug
>  Components: Sling Models
>Affects Versions: Sling Models Impl 1.4.10
> Environment: Java SE 1.8.0_231
>Reporter: Frank Pauleickhoff
>Priority: Major
>
> In AEM 6.4 ServicePack 6 we face NullPointerExceptions when using the Sling 
> model cache that used to work before (in SP 3).
> *Exception Stacktrace is:*
> {code:java}
> 22.11.2019 15:29:22.525 *ERROR* [127.0.0.1 [1574432957337] GET 
> /content/mypage.html HTTP/1.1] 
> org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught 
> SlingException
> org.apache.sling.scripting.sightly.SightlyException: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: 
> Identifier xx.xxx.MyModel cannot be correctly instantiated by the Use API
> [...]
> Caused by: java.lang.NullPointerException: null
>  at 
> org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:407)
>  at 
> org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:314)
> {code}
> Problem seems to be related to introduction of WeakReferences in SLING-7586. 
> Without knowing any details and being deeply into the Sling Model Caching 
> implementation, I think a null-check is missing for "SoftReference" in Line 
> 407:
> {code:java}
> SoftReference SoftReference = adaptableCache.get(requestedType);
> ModelType cachedObject = (ModelType) SoftReference.get();
> {code}
> That seems to cause caching to throw NPE for any not yet cached model.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (SLING-8706) Injections for java.util.Optional<> should be automatic optional

2019-11-16 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-8706:
---

Thanks for the detailed explanation, [~joerghoh] I'll start with the 
implementation.

> Injections for java.util.Optional<> should be automatic optional 
> -
>
> Key: SLING-8706
> URL: https://issues.apache.org/jira/browse/SLING-8706
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Reporter: Jörg Hoh
>Priority: Major
>
> The current approach to support optional injections requires to annotate the 
> field with {{@Optional}} plus proper handling within the javacode (null 
> checks etc), which can be forgotten.
> So instead of
> {code}
> @Inject @Optional
> String fieldname;
> {code}
> it should also be possible to use this
> {code}
> @Inject
> Optional fieldname;
> {code}
> with the very same semantic. But the developer is forced to deal with the 
> case that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Comment Edited] (SLING-8706) Injections for java.util.Optional<> should be automatic optional

2019-11-14 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev edited comment on SLING-8706 at 11/14/19 8:03 PM:
-

Thanks, [~sseifert] this exactly what I meant.


was (Author: etugarev):
Thanks, [~sseifert] this exactly what I meant. I'll check for other tickets :)

> Injections for java.util.Optional<> should be automatic optional 
> -
>
> Key: SLING-8706
> URL: https://issues.apache.org/jira/browse/SLING-8706
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Reporter: Jörg Hoh
>Priority: Major
>
> The current approach to support optional injections requires to annotate the 
> field with {{@Optional}} plus proper handling within the javacode (null 
> checks etc), which can be forgotten.
> So instead of
> {code}
> @Inject @Optional
> String fieldname;
> {code}
> it should also be possible to use this
> {code}
> @Inject
> Optional fieldname;
> {code}
> with the very same semantic. But the developer is forced to deal with the 
> case that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (SLING-8706) Injections for java.util.Optional<> should be automatic optional

2019-11-14 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-8706:
---

Thanks, [~sseifert] this exactly what I meant. I'll check for other tickets :)

> Injections for java.util.Optional<> should be automatic optional 
> -
>
> Key: SLING-8706
> URL: https://issues.apache.org/jira/browse/SLING-8706
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Reporter: Jörg Hoh
>Priority: Major
>
> The current approach to support optional injections requires to annotate the 
> field with {{@Optional}} plus proper handling within the javacode (null 
> checks etc), which can be forgotten.
> So instead of
> {code}
> @Inject @Optional
> String fieldname;
> {code}
> it should also be possible to use this
> {code}
> @Inject
> Optional fieldname;
> {code}
> with the very same semantic. But the developer is forced to deal with the 
> case that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (SLING-8706) Injections for java.util.Optional<> should be automatic optional

2019-11-11 Thread Evgeny Tugarev (Jira)


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

Evgeny Tugarev commented on SLING-8706:
---

I can have a look on implementing this, however I am slightly concerned that 
_Optional_ class is not serializable. I think this will introduce an artificial 
limitation and may be problematic in long run. Please correct me if I am wrong.

> Injections for java.util.Optional<> should be automatic optional 
> -
>
> Key: SLING-8706
> URL: https://issues.apache.org/jira/browse/SLING-8706
> Project: Sling
>  Issue Type: Improvement
>  Components: Sling Models
>Reporter: Jörg Hoh
>Priority: Major
>
> The current approach to support optional injections requires to annotate the 
> field with {{@Optional}} plus proper handling within the javacode (null 
> checks etc), which can be forgotten.
> So instead of
> {code}
> @Inject @Optional
> String fieldname;
> {code}
> it should also be possible to use this
> {code}
> @Inject
> Optional fieldname;
> {code}
> with the very same semantic. But the developer is forced to deal with the 
> case that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)