Skip to content

Avoid NullPointerException when deserializing TestIdentifier - #3820

Merged
marcphilipp merged 3 commits into
junit-team:mainfrom
dmlloyd:fix-3819
May 16, 2024
Merged

marcphilipp merged 3 commits into
junit-team:mainfrom
dmlloyd:fix-3819

Conversation

@dmlloyd

@dmlloyd dmlloyd commented May 16, 2024 •

Copy link
Copy Markdown
Contributor

Overview

Fix NullPointerException when a TestIdentifier with no parentId is deserialized.

Issue: #3819


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@marcphilipp marcphilipp linked an issue May 16, 2024 that may be closed by this pull request
1 task done

@marcphilipp marcphilipp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for reporting and providing a fix! Could you please add a test to org.junit.platform.launcher.TestIdentifierTests to cover this scenario? It should suffice to serialize and deserialize TestIdentifier.from(engineDescriptor).

@dmlloyd

dmlloyd commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

I've pushed up a test (and good thing too, because it uncovered a second place where the problem occurs). I don't really understand how the descriptors and identifiers work together though so I just created an anonymous instance of TestDescriptors with the exact characteristics that trigger the problem. Is that OK?

@dmlloyd

dmlloyd commented May 16, 2024 •

Copy link
Copy Markdown
Contributor Author

Hmm CI is failing due to a spotless check for a file I didn't touch: https://github.com/junit-team/junit5/actions/runs/9114769155/job/25059506872?pr=3820#step:3:731

Did I mess something up somehow?

To quote the great man: "I wasn't even in aisle seven!"

@dmlloyd

dmlloyd commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

Also one more question... is there any chance that this change could be backported into a 5.10.3 release?

@marcphilipp

Copy link
Copy Markdown
Member

I don't really understand how the descriptors and identifiers work together though so I just created an anonymous instance of TestDescriptors with the exact characteristics that trigger the problem. Is that OK?

I polished the test to make it more like the others in that class in 85a300c.

Hmm CI is failing due to a spotless check for a file I didn't touch: junit-team/junit5/actions/runs/9114769155/job/25059506872?pr=3820#step:3:731

Did I mess something up somehow?

That was my bad. Earlier today, I pushed something to main that broke that. I just fixed it and merged the fix into your branch. Should be good now.

Also one more question... is there any chance that this change could be backported into a 5.10.3 release?

Would a 5.11.0-M2 release also work for you?

@dmlloyd

dmlloyd commented May 16, 2024

Copy link
Copy Markdown
Contributor Author

I don't really understand how the descriptors and identifiers work together though so I just created an anonymous instance of TestDescriptors with the exact characteristics that trigger the problem. Is that OK?

I polished the test to make it more like the others in that class in 85a300c.

Great! Thanks.

Hmm CI is failing due to a spotless check for a file I didn't touch: junit-team/junit5/actions/runs/9114769155/job/25059506872?pr=3820#step:3:731
Did I mess something up somehow?

That was my bad. Earlier today, I pushed something to main that broke that. I just fixed it and merged the fix into your branch. Should be good now.

Awesome!

Also one more question... is there any chance that this change could be backported into a 5.10.3 release?

Would a 5.11.0-M2 release also work for you?

I'm not sure; I'll follow up once I've consulted with the team.

@geoand

geoand commented May 16, 2024 •

Copy link
Copy Markdown

Would a 5.11.0-M2 release also work for you?

Is there any chance we can see a preliminary changelog for 5.11?
We have never encountered any issues upgrading in the past, but I would nevertheless like us to do our due diligence :)

@marcphilipp

marcphilipp commented May 16, 2024 •

Copy link
Copy Markdown
Member

Sure, here are the release notes for M1 and the preliminary ones for M2.

@geoand

geoand commented May 16, 2024

Copy link
Copy Markdown

Thanks!

@marcphilipp
marcphilipp merged commit bc55d0e into junit-team:main May 16, 2024
@dmlloyd
dmlloyd deleted the fix-3819 branch May 16, 2024 15:56
@marcphilipp

Copy link
Copy Markdown
Member

@dmlloyd @geoand We just released 5.11.0-M2

@geoand

geoand commented May 17, 2024

Copy link
Copy Markdown

🙏

@geoand

geoand commented May 22, 2024 •

Copy link
Copy Markdown

@marcphilipp thanks again, for the release!
We tried and it and this fix works expected, however because the milestone release has some other effects that we would ideally like to avoid dealing with until a GA, release, is there any chance we could get a 5.10.3?

Thanks a lot

@dmlloyd

dmlloyd commented May 29, 2024

Copy link
Copy Markdown
Contributor Author

And relatedly, would it be useful if I put up a backport of this PR to the 5.10.x branch?

@dmlloyd

dmlloyd commented May 30, 2024

Copy link
Copy Markdown
Contributor Author

Just in case, I've opened #3837.

@sbrannen

Copy link
Copy Markdown
Member

@dmlloyd and @geoand,

I've opened #3838 so the team can consider backporting selected bug fixes to 5.10.x.

@geoand

geoand commented May 31, 2024

Copy link
Copy Markdown

Thanks a lot @sbrannen!

@sbrannen sbrannen changed the title Fix NPE when deserializing TestIdentifier Fix NullPointerException when deserializing TestIdentifier May 31, 2024
@sbrannen sbrannen changed the title Fix NullPointerException when deserializing TestIdentifier Avoid NullPointerException when deserializing TestIdentifier May 31, 2024
marcphilipp pushed a commit that referenced this pull request Jun 17, 2024
An NPE was thrown when (de)serializing `TestIdentifiers` without a parent.

Fixes #3819.

Co-authored-by: Marc Philipp <mail@marcphilipp.de>

(cherry picked from commit bc55d0e)
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.

NullPointerException when deserializing TestIdentifier

4 participants