Skip to content

Commit

Permalink
[jvm-packages] handle null to avoid potential NullPointerException
Browse files Browse the repository at this point in the history
  • Loading branch information
ShangjinTang committed Jun 28, 2024
1 parent 824fba7 commit a9cb728
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ private TrackerProperties() {
InputStream inputStream = null;

try {
URL propertiesFileURL =
Thread.currentThread().getContextClassLoader().getResource(PROPERTIES_FILENAME);
if (propertiesFileURL != null){
inputStream = propertiesFileURL.openStream();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if (classLoader != null) {
URL propertiesFileURL = classLoader.getResource(PROPERTIES_FILENAME);
if (propertiesFileURL != null) {
inputStream = propertiesFileURL.openStream();
}
}
} catch (IOException e) {
logger.warn("Could not load " + PROPERTIES_FILENAME + " file. ", e);
Expand Down

0 comments on commit a9cb728

Please sign in to comment.