Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SLING-12394 improve ResourceResolver handling #39

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

joerghoh
Copy link
Contributor

  • Open all ResourceResolvers in a try-with-resource-based approach, which make the code easier to read
  • remove redundant nullchecks

* @throws RuntimeException if the resolver can't be created.
*/
public ResourceResolver createResourceResolver() {
ResourceResolver resolver = null;
public @NotNull ResourceResolver createResourceResolver() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC this change will result in exceptions rather than silent swallows if the factory is null. That might its own consequences. What is the reasoning behind this change?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @stefan-egli's concern. There are quite a few places where we had a null check before.

@joerghoh I suggest to throw a NullPointerException (or something more specific) instead of a RuntimeException and to catch and log this exception in the places where we used to have a null check.

* @throws RuntimeException if the resolver can't be created.
*/
public ResourceResolver createResourceResolver() {
ResourceResolver resolver = null;
public @NotNull ResourceResolver createResourceResolver() {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @stefan-egli's concern. There are quite a few places where we had a null check before.

@joerghoh I suggest to throw a NullPointerException (or something more specific) instead of a RuntimeException and to catch and log this exception in the places where we used to have a null check.

Comment on lines -144 to -145
final ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -334 to -335
ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -390 to -391
final ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -75 to -76
final ResourceResolver resolver = this.configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -200 to -201
final ResourceResolver resolver = this.configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -396 to -397
final ResourceResolver resolver = this.configuration.createResourceResolver();
if ( resolver == null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -64 to -65
final ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver == null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -85 to -86
final ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Comment on lines -158 to -159
final ResourceResolver resolver = configuration.createResourceResolver();
if ( resolver != null ) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have a null check. Should we handle the exception here instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants