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

[Improvement] Possible null pointer exception in CatalogRegister.java #4189

Open
justinmclean opened this issue Jul 18, 2024 · 13 comments
Open
Assignees
Labels
good first issue Good for newcomers improvement Improvements on everything

Comments

@justinmclean
Copy link
Member

What would you like to be improved?

In checkCatalogExist, failedException is set to null and then thrown which could cause a NPE if it is not set in the exception block.

How should we improve?

Move throw failedException; to the correct place in the catch block?

@justinmclean justinmclean added good first issue Good for newcomers improvement Improvements on everything labels Jul 18, 2024
@justinmclean justinmclean changed the title [Improvement] Possible nukl pointer exception in CatalogRegister.java [Improvement] Possible null pointer exception in CatalogRegister.java Jul 18, 2024
@simarjeetss
Copy link

Hello @justinmclean , can I have a look on this? I think I can resolve this.

@justinmclean
Copy link
Member Author

Thanks for taking a look I have assigned it to you

@simarjeetss
Copy link

I am thinking of removing the failedException variable, moving exception handling inside the retry loop, and directly throwing a TrinoException when retries are exhausted. I also thought of adding proper InterruptedException handling. I think these modifications can enhance the method's robustness and error management.

What do you think about this?

@simarjeetss
Copy link

simarjeetss commented Jul 18, 2024

I made some changes to fix the NPE and improve the method. Please have a look :-
#4201

@yuqi1129
Copy link
Contributor

@simarjeetss
I suggest you check similar problem in the whole project and fix them together.

@justinmclean
Copy link
Member Author

This as far as I know is the only case where a NPE could happen in this way

@simarjeetss
Copy link

can u elaborate on this please

@justinmclean
Copy link
Member Author

@yuqi1129 are you aware of any other cases where this might occur?

@yuqi1129
Copy link
Contributor

@justinmclean
I haven't found any similar issues yet. Perhaps I need to use a code quality tool to check the project. If you find itsatisfactory now, please proceed.

@diqiu50
Copy link
Contributor

diqiu50 commented Jul 19, 2024

@simarjeetss I think we can initialize failedException to avoid this problem.
···
Exception failedException = new TrinoException(GENERIC_INTERNAL_ERROR)
···

@justinmclean
Copy link
Member Author

@simarjeetss what do you think?

@justinmclean
Copy link
Member Author

@simarjeetss Do you want to still work on this?

@simarjeetss
Copy link

Yes, I'll continue working on this right now. I've been busy with other important work lately. Sorry for the inconvenience

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers improvement Improvements on everything
Projects
None yet
Development

No branches or pull requests

4 participants