[jira] [Commented] (SLING-8858) Model Cache causes NPE in sling.models.impl 1.4.10+
[ https://issues.apache.org/jira/browse/SLING-8858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17060171#comment-17060171 ] Dan Klco commented on SLING-8858: - Provided patch looks good to me as well. Moving to resolved. > 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 >Assignee: Dan Klco >Priority: Major > Fix For: Sling Models Impl 1.4.14 > > Time Spent: 40m > Remaining Estimate: 0h > > 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+
[ https://issues.apache.org/jira/browse/SLING-8858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17060120#comment-17060120 ] Carsten Ziegeler commented on SLING-8858: - The provided patch looks good to me, thanks . I just applied it [~dklco] Could you please cross check? > 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 > Fix For: Sling Models Impl 1.4.14 > > Time Spent: 40m > Remaining Estimate: 0h > > 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+
[ https://issues.apache.org/jira/browse/SLING-8858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17060107#comment-17060107 ] Henry Kuijpers commented on SLING-8858: --- Can someone please have a look at the provided PR? We're currently affected by this bug and I think the fix is quite straightforward. WDYT [~cziegeler]? > 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 > Fix For: Sling Models Impl 1.4.14 > > Time Spent: 0.5h > Remaining Estimate: 0h > > 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+
[ 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)