RFR: 8303: NPE at org.openjdk.jmc.flightrecorder.rules.report.JfrRulesReport.addReport

Marcus Hirt hirt at openjdk.org
Thu Dec 12 22:52:44 UTC 2024


On Thu, 12 Dec 2024 06:25:11 GMT, Suchita Chaturvedi <schaturvedi at openjdk.org> wrote:

>> One of our customers is trying to generate XML report using below mentioned command.
>> 
>> java -cp ".\common-9.1.0-SNAPSHOT.jar;.\flightrecorder-9.1.0-SNAPSHOT.jar;.\flightrecorder.rules-9.1.0-SNAPSHOT.jar;.\flightrecorder.rules.jdk-9.1.0-SNAPSHOT.jar;.\lz4-java_1.8.0.jar;.\org.owasp.encoder_1.2.3.jar" org.openjdk.jmc.flightrecorder.rules.report.JfrRulesReport JFRFileName.jfr -verbose -format xml > XmlFileName.xml
>> 
>> The report is not generated and the console is showing NullPointerException as below:
>> 
>> Caused by: java.lang.NullPointerException: Cannot invoke "org.openjdk.jmc.common.item.IMemberAccessor.getMember(Object)" because "a" is null
>> at org.openjdk.jmc.flightrecorder.rules.report.JfrRulesReport.addReport(JfrRulesReport.java:331)
>> at com.oracle.psr.pcl.analyzers.jmc.JMCParserProcess.call(JMCParserProcess.java:82)
>> at com.oracle.psr.pcl.analyzers.jmc.JMCParserProcess.call(JMCParserProcess.java:36)
>> at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
>> at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
>> at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
>> at java.base/java.lang.Thread.run(Thread.java:842) 
>
> core/org.openjdk.jmc.flightrecorder.rules/src/main/java/org/openjdk/jmc/flightrecorder/rules/report/JfrRulesReport.java line 332:
> 
>> 330: 								itemsNode.appendChild(itemNode);
>> 331: 								for (IMemberAccessor<?, IItem> a : accessors) {
>> 332: 									if (a != null)
> 
> Added this null check here to avoid further NPEs due to null accessors.

This shouldn't happen normally. Should there be some logging so that we can discover if it does?

> core/org.openjdk.jmc.flightrecorder/src/main/java/org/openjdk/jmc/flightrecorder/jdk/JdkQueries.java line 157:
> 
>> 155: 			.select(ALLOC_INSIDE_TLAB_AVG).select(ALLOC_INSIDE_TLAB_SUM).groupBy(EVENT_THREAD).build();
>> 156: 	public static final IItemQuery JFR_DATA_LOST = fromWhere(JdkFilters.JFR_DATA_LOST)
>> 157: 			.select(END_TIME, EVENT_THREAD, FLR_DATA_LOST).build();
> 
> Removed the unnecessary usage of Event Thread here which was causing issue. Since there was no event thread attribute for jdk.DataLoss event, hence there was no matching accessor also and it was throwing NPE due to null accessor when report was generated using verbose option. Issue was present for both XML and HTML report generation but customer has reported it for XML only.

When dumping the recording, there is no event thread in the metadata of the event, so removing EVENT_THREAD sounds right, but shouldn't you leave the query?

-------------

PR Review Comment: https://git.openjdk.org/jmc/pull/616#discussion_r1882992656
PR Review Comment: https://git.openjdk.org/jmc/pull/616#discussion_r1882993182


More information about the jmc-dev mailing list