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

[ttools-3.4.9] NullPointerException in PrintSaxMessager during test #67

Closed
olebole opened this issue Dec 14, 2023 · 1 comment
Closed

Comments

@olebole
Copy link
Contributor

olebole commented Dec 14, 2023

When running the VersionDetailTest, I get the following exception with the latest ttools release (3.4.9):

Testcase: testVersions(uk.ac.starlink.ttools.votlint.VersionDetailTest):	Caused an ERROR
Cannot invoke "java.io.PrintStream.println(String)" because "this.out_" is null
java.lang.NullPointerException: Cannot invoke "java.io.PrintStream.println(String)" because "this.out_" is null
	at uk.ac.starlink.ttools.votlint.PrintSaxMessager.reportMessage(PrintSaxMessager.java:75)
	at uk.ac.starlink.ttools.votlint.VotLintContext.warning(VotLintContext.java:257)
	at uk.ac.starlink.ttools.votlint.VersionDetail.getInstance(VersionDetail.java:118)
	at uk.ac.starlink.ttools.votlint.VersionDetailTest.getDetail(VersionDetailTest.java:34)
	at uk.ac.starlink.ttools.votlint.VersionDetailTest.testVersions(VersionDetailTest.java:14)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

The reason seems that in VersionDetailTest, the PrintSaxMessager is constructed as

which sets the _outl attribute to null. Any attempt to print a warning will then ofcourse create the NPE:

/* Output the message. */
out_.println( text );

I am not sure why I create a warning here which was not in your CI tests; this may happen because of some slightly different versions (ADQLLib?); however maybe the _outl attribute should probably be checked for null before used (or a real output stream should applied in the test?)

mbtaylor added a commit that referenced this issue Dec 15, 2023
In one test case, PrintSaxMessager was constructed with a null
print stream.  In my tests no messages got sent so this hadn't
caused a problem, but testing in other environments
(different JAXP implementations?) did produce some output messages,
hence resulted in a NullPointerException.  Supply a non-null
PrintStream (System.out) instead.  I don't know why I didn't do
this in the first place.

This bug was reported by Ole Streicher (starjava issue #67).
@mbtaylor
Copy link
Member

@olebole you are quite right. Fixed in 417ed4e. Many thanks for the report.

@olebole olebole closed this as completed Dec 20, 2023
mmpcn pushed a commit that referenced this issue Oct 25, 2024
In one test case, PrintSaxMessager was constructed with a null
print stream.  In my tests no messages got sent so this hadn't
caused a problem, but testing in other environments
(different JAXP implementations?) did produce some output messages,
hence resulted in a NullPointerException.  Supply a non-null
PrintStream (System.out) instead.  I don't know why I didn't do
this in the first place.

This bug was reported by Ole Streicher (starjava issue #67).
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

No branches or pull requests

2 participants