Skip to content

HDFS-17876. Add null check for tracer in NameNode.stop() to avoid NPE…#8336

Open
deepujain wants to merge 1 commit intoapache:trunkfrom
deepujain:HDFS-17876-namenode-tracer-null-check
Open

HDFS-17876. Add null check for tracer in NameNode.stop() to avoid NPE…#8336
deepujain wants to merge 1 commit intoapache:trunkfrom
deepujain:HDFS-17876-namenode-tracer-null-check

Conversation

@deepujain
Copy link
Contributor

Summary

NameNode.stop() called tracer.close() without a null check. If the NameNode is stopped before tracer is initialized (e.g. exception in parent constructor, or stopAtException() during failed startup), this caused an NPE at line 1116 and obscured the original failure.

Change

  • NameNode.java: In stop(), guard tracer.close() with if (tracer != null) so shutdown completes without NPE when tracer was never set.
  • TestNameNodeReconfigure.java: Added testStopWithNullTracerDoesNotThrow() which sets tracer to null via reflection and calls stop(); verifies no NPE (HDFS-17876).

JIRA

Fixes HDFS-17876

Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

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

I think we can live without the test, it isn't testing something relevant, we are ourselves making it null via reflection,

We can drop the test, I am happy to merge it like that, if others don't object

@deepujain
Copy link
Contributor Author

deepujain commented Mar 12, 2026

Rebased on trunk. Dropped the test per @ayushtkn review. Ready for CI.

Adding unit tests is generally a good idea.

@deepujain deepujain force-pushed the HDFS-17876-namenode-tracer-null-check branch from df7c7f6 to 16f73a0 Compare March 12, 2026 16:01
@hadoop-yetus
Copy link

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 46s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 1s codespell was not available.
+0 🆗 detsecrets 0m 1s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
-1 ❌ test4tests 0m 0s The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch.
_ trunk Compile Tests _
+1 💚 mvninstall 43m 55s trunk passed
+1 💚 compile 1m 48s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 1m 47s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 1m 53s trunk passed
+1 💚 mvnsite 1m 58s trunk passed
+1 💚 javadoc 1m 32s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 1m 33s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 4m 15s trunk passed
+1 💚 shadedclient 31m 25s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 1m 21s the patch passed
+1 💚 compile 1m 13s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 1m 13s the patch passed
+1 💚 compile 1m 16s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 1m 16s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 1m 16s the patch passed
+1 💚 mvnsite 1m 23s the patch passed
+1 💚 javadoc 0m 57s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 1m 0s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 3m 48s the patch passed
+1 💚 shadedclient 30m 7s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 215m 29s /patch-unit-hadoop-hdfs-project_hadoop-hdfs.txt hadoop-hdfs in the patch passed.
+1 💚 asflicense 0m 47s The patch does not generate ASF License warnings.
347m 53s
Reason Tests
Failed junit tests hadoop.hdfs.server.datanode.fsdataset.impl.TestFsVolumeList
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8336/2/artifact/out/Dockerfile
GITHUB PR #8336
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 1c38b5bf0554 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 16f73a0
Default Java Ubuntu-17.0.18+8-Ubuntu-124.04.1
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.10+7-Ubuntu-124.04 /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.18+8-Ubuntu-124.04.1
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8336/2/testReport/
Max. process+thread count 3559 (vs. ulimit of 5500)
modules C: hadoop-hdfs-project/hadoop-hdfs U: hadoop-hdfs-project/hadoop-hdfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8336/2/console
versions git=2.43.0 maven=3.9.11 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

ayushtkn
ayushtkn previously approved these changes Mar 13, 2026
Copy link
Member

@ayushtkn ayushtkn left a comment

Choose a reason for hiding this comment

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

LGTM

@ayushtkn
Copy link
Member

My Bad I realise, there is already an older open PR for the ticket: #8200

@ayushtkn ayushtkn dismissed their stale review March 13, 2026 05:33

Dupe PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants