-
Notifications
You must be signed in to change notification settings - Fork 202
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
java.lang.NullPointerException when upgraded to kotlin 2.0 #519
Comments
We have the same Problem, is there something we can do about it? |
+1 here |
+1 |
I am facing the same issue. My setup:
Even though I'm checking that myRepository is not null, both in the test class, before calling the method tested and inside the method, before the repository does a save. And yet, Edit: `when`(myRepository.save(notNull(MyEntity::class.java))).thenAnswer(AdditionalAnswers.returnsFirstArg<MyEntity>) This would be nice to be auto-configured, somehow. I am guessing that the Kotlin compiler is able to be more strict in this case, compared to Kotlin 1.9, which was more lenient and the build was passing. |
@hanrw I have tested my finding on your reproducible project. You have a commented-out line there, replace it with: whenever(userStatusRepository.save(Mockito.notNull(UserStatus::class.java)))
.thenAnswer(AdditionalAnswers.returnsFirstArg<UserStatus>()) ... and it works. |
gradle config
test
service
repository
and got error
here's reproducing repo and it works after downgrading to kotlin 1.9.24
archive.zip
The text was updated successfully, but these errors were encountered: