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

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Vikas Saurabh
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
Reply | Threaded
Open this post in threaded view
|

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

Robert Munteanu-2
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