[
https://issues.apache.org/jira/browse/SLING-8079?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17039920#comment-17039920
]
Konrad Windszus commented on SLING-8079:
----------------------------------------
[~justinedelson] How do you think this should be fixed best? The logging at
https://github.com/apache/sling-org-apache-sling-models-impl/blame/master/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java#L270
was deliberately introduced with
https://issues.apache.org/jira/browse/SLING-5389. I think we need a special
flag in case no exception was thrown but still PostConstruct returned false,
which is supposed to be evaluates as well prior to logging. Since
{{ModelFactory.createModel}} must not return {{null}} we should use another
dedicated exception for PostConstruct returning {{false}} (also with lower log
level).
> Returning false in a model PostConstruct causes an
> java.lang.IllegalStateException
> ----------------------------------------------------------------------------------
>
> Key: SLING-8079
> URL: https://issues.apache.org/jira/browse/SLING-8079
> Project: Sling
> Issue Type: Bug
> Components: Sling Models
> Affects Versions: Sling Models Impl 1.4.6
> Reporter: Santiago García Pimentel
> Priority: Major
> Fix For: Sling Models Impl 1.4.14
>
>
> I was just trying the exporter framework and the feature from SLING-7124,
> where you can return false in a post construct to prevent a model to being
> returned.
> Unfortunately I found myself with an IllegalStateException:
>
> {quote}java.lang.IllegalStateException: No throwable available at
> org.apache.sling.models.impl.Result.getThrowable(Result.java:61) at
> org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:316)
> at
> org.apache.sling.models.impl.ExportServlet$RequestAccessor.getExportedString(ExportServlet.java:202)
> at org.apache.sling.models.impl.ExportServlet.doGet(ExportServlet.java:106)
> at
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.mayService(SlingSafeMethodsServlet.java:266)
> at
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:342)
> at
> org.apache.sling.api.servlets.SlingSafeMethodsServlet.service(SlingSafeMethodsServlet.java:374)
> at
> org.apache.sling.engine.impl.request.RequestData.service(RequestData.java:552){quote}
> It seems like the ModelAdapterFactory assumes that there should be an
> exception if a model was not returned, which is no longer the case. I don't
> think this exception should be thrown.
> The easiest solution I think is to make o.a.s.models.impl.Result not throw
> that exception and let the ModelAdapterFactory handle it, but Im not sure
> that would the be most appropriate way.
>
>
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)