Skip to content

Conversation

@AlbertLovers
Copy link
Contributor

Validate the order of the argument types against the order of the parameters. The previous version ignored mismatches and returned the first method with the correct name and correct number of parameters regardless of parameter types.

Validate the order of the argument types against the order of the parameters. The previous version ignored mismatches and returned the first method with the correct name and correct number of parameters regardless of parameter types.
@cowtowncoder
Copy link
Member

First of all, thank you for contributing this fix!

Second: one (and only) process thing we have is that we need CLA from:

https://github.com/FasterXML/jackson/blob/main/contributor-agreement.pdf

before the first PR (but only needs to be sent once, good for all future contributions).
The easiest way is usually to print it, fill & sign, email to cla at fasterxml dot com.
Once I get it, I can merge the PR.

Third: is there specific problem case this solves? If so, would it be possible to add a unit test to guard against regression?

@AlbertLovers
Copy link
Contributor Author

The contributor agreement is on its way.

Third: is there specific problem case this solves? If so, would it be possible to add a unit test to guard against regression?

I did not run into a specific issue with the code, I discovered the issue while looking through the JavaTimeModule while working on a migration. It seems to me the for loop checking the types is either important but broken (which makes me wonder why there are no bug reports) or it is superfluous and needs to be removed.

Unfortunately the JavaTimeModule does not seem to have unit tests yet and I am not familiar enough with the workings of AnnotatedClass and AnnotatedMethod to write meaningful tests.

I can write tests for the _findFactory method if you don't mind me introducing something like Mockito to the testsuite.

@cowtowncoder
Copy link
Member

cowtowncoder commented Dec 31, 2025

@AlbertLovers Ah ok. Looking at code it's called just once,a s

AnnotatedMethod factory = _findFactory(ac, "of", String.class);

for ZoneId.

Given this, I think it's ok not to write mock-based test; some indirect testing probably exists wrt deserialization of JDK ZoneId instances.

Fix itself makes sense.

@cowtowncoder cowtowncoder added the cla-received Marker to denote that there is a CLA for pr label Dec 31, 2025
@cowtowncoder cowtowncoder changed the title Update JavaTimeModule.java Fix a potential problem in JavaTimeModule._findFactory() Dec 31, 2025
@cowtowncoder
Copy link
Member

Actually... no, looks like this code never gets executed. Oh well. Even less point in writing mock tests.

@cowtowncoder cowtowncoder merged commit aa4de63 into FasterXML:2.x Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-received Marker to denote that there is a CLA for pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants