You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Vikas Saurabh <vi...@gmail.com> on 2018/10/31 12:09:47 UTC

JcrResourceResolver#findResources seems to eat exceptions while iterating but not during initialization

Hi,

Recently, while working on a separate issue, I landed on a seemingly
different behavior while finding resources via jcr resource resolver.

It seems that while finding resources JcrNodeResourceIterator [1] eats
exceptions while iterating over underlying result set. It logs and
ERROR though. Otoh, if some error occurs while creating the iterator
(say while doing getNodes [2]) then the exception gets thrown back to
caller (without any log message). While throw-or-log-error strategy, I
think, seems right, but the different in behavior for caller of
findResource seems incorrect to me. I think it should be consistent
one way or another.

That said, imo, I think the iterator is wrong here to assume that it's
ok to just log and error and continue with iteration without notifying
the caller - but I don't think I'm able enough to make such a call.

I'd love to hear inputs from this list (didn't open the issue because
I didn't really know if my feeling is really considered an issue or
not).

[1]: https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/org.apache.sling.jcr.resource-3.0.16/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResourceIterator.java#L127
[2]: https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/org.apache.sling.jcr.resource-3.0.16/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/BasicQueryLanguageProvider.java#L83

Thanks,
Vikas

Re: JcrResourceResolver#findResources seems to eat exceptions while iterating but not during initialization

Posted by Robert Munteanu <ro...@apache.org>.
Hi Vikas,

On Wed, 2018-10-31 at 17:39 +0530, Vikas Saurabh wrote:
> Hi,
> 
> Recently, while working on a separate issue, I landed on a seemingly
> different behavior while finding resources via jcr resource resolver.
> 
> It seems that while finding resources JcrNodeResourceIterator [1]
> eats
> exceptions while iterating over underlying result set. It logs and
> ERROR though. Otoh, if some error occurs while creating the iterator
> (say while doing getNodes [2]) then the exception gets thrown back to
> caller (without any log message). While throw-or-log-error strategy,
> I
> think, seems right, but the different in behavior for caller of
> findResource seems incorrect to me. I think it should be consistent
> one way or another.
> 
> That said, imo, I think the iterator is wrong here to assume that
> it's
> ok to just log and error and continue with iteration without
> notifying
> the caller - but I don't think I'm able enough to make such a call.
> 
> I'd love to hear inputs from this list (didn't open the issue because
> I didn't really know if my feeling is really considered an issue or
> not).

I don't have extra knowledge about this unforunately, but here's some
information I found by looking thorugh the commit history.

1. There was an addition for SLING-2408 [1] which refined this by
adding a new catch block handling missing nodes with commit [2].

2. That block was removed for SLING-3848 [3] with commit [4], which
might not have been intentional.

In the end, I can't really say what this catch block is guarding
against. Can you add more details regarding which kind of error is
being logged?

Thanks,
Robert

[1]: https://issues.apache.org/jira/browse/SLING-2408
[2]: https://github.com/apache/sling-org-apache-sling-jcr-resource/commit/478bc4e6
[3]: https://issues.apache.org/jira/browse/SLING-3848
[4]: https://github.com/apache/sling-org-apache-sling-jcr-resource/commit/a9d91b2d