Skip to content

HDFS-16029. Fix ArrayIndexOutOfBoundsException and divide-by-zero in InstrumentationService.Timer.getValues()#8420

Open
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-16029
Open

HDFS-16029. Fix ArrayIndexOutOfBoundsException and divide-by-zero in InstrumentationService.Timer.getValues()#8420
balodesecurity wants to merge 1 commit intoapache:trunkfrom
balodesecurity:HDFS-16029

Conversation

@balodesecurity
Copy link
Copy Markdown
Contributor

Summary

  • InstrumentationService.Timer.getValues() throws ArrayIndexOutOfBoundsException (index -1) and would divide by zero when called on a freshly constructed Timer before any Cron has been recorded (last == -1).
  • Fix: return an all-zeros array immediately when last < 0, matching the suggestion in the JIRA ticket. This is the same defensive pattern used in Sampler.getRate() which guards against last == 0.

Test

  • Added timerGetValuesBeforeAnyCron() to TestInstrumentationService — creates a fresh Timer(2), asserts getValues() returns zeros without exception, and also asserts toJSONString() does not throw.
  • All 7 tests in TestInstrumentationService pass.

@hadoop-yetus
Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 19m 6s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 41m 8s trunk passed
+1 💚 compile 0m 56s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 compile 0m 55s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 checkstyle 0m 57s trunk passed
+1 💚 mvnsite 1m 8s trunk passed
+1 💚 javadoc 0m 57s trunk passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 55s trunk passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 1m 16s trunk passed
+1 💚 shadedclient 28m 22s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 24s the patch passed
+1 💚 compile 0m 23s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javac 0m 23s the patch passed
+1 💚 compile 0m 24s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 javac 0m 24s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 20s the patch passed
+1 💚 mvnsite 0m 33s the patch passed
+1 💚 javadoc 0m 23s the patch passed with JDK Ubuntu-21.0.10+7-Ubuntu-124.04
+1 💚 javadoc 0m 24s the patch passed with JDK Ubuntu-17.0.18+8-Ubuntu-124.04.1
+1 💚 spotbugs 0m 55s the patch passed
+1 💚 shadedclient 27m 11s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 5m 18s hadoop-hdfs-httpfs in the patch passed.
+1 💚 asflicense 0m 36s The patch does not generate ASF License warnings.
136m 11s
Subsystem Report/Notes
Docker ClientAPI=1.54 ServerAPI=1.54 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8420/1/artifact/out/Dockerfile
GITHUB PR #8420
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux ba87e5f739e5 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / a6a4ddf
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-8420/1/testReport/
Max. process+thread count 959 (vs. ulimit of 10000)
modules C: hadoop-hdfs-project/hadoop-hdfs-httpfs U: hadoop-hdfs-project/hadoop-hdfs-httpfs
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8420/1/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.

@pan3793
Copy link
Copy Markdown
Member

pan3793 commented Apr 13, 2026

@balodesecurity, please strictly follow pull_request_template, especially, answer the question - whether the PR "Contains content generated by <tool>", for more details, read ASF Generative Tooling Guidance

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.

4 participants