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

[jvm-packages] handle null to avoid potential NullPointerException #10499

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

Conversation

ShangjinTang
Copy link

This PR add null checks for jvm-packages/xgboost4j/src/main/java/ml/dmlc/xgboost4j/java/TrackerProperties.java.

It retrieves the current thread's class loader using Thread.currentThread().getContextClassLoader() and verifies if it is not null.

@trivialfis
Copy link
Member

Hi, thank you for the PR. Could you please elaborate on under what circumstances it would be null, and what happens if it's null after this PR?

@ShangjinTang
Copy link
Author

Hello,

This is a failure that we scanned from our static code check tool and marked as "must be fixed".
I also searched from web, some developers have occured that Thread.currentThread().getContextClassLoader() might be null (although I cannot reproduce the issue).
I am using the xgboost4j library on Android, so the entire process would crash if contextClassLoader is null.

Thanks

@wbo4958
Copy link
Contributor

wbo4958 commented Jul 5, 2024

Looks like TrackerProperties.java is not used anymore after tracker reworking.

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