[JAVA-4119] NPE in PojoBuilderHelper where static methods follow bean convention Created: 27/Apr/21  Updated: 28/Oct/23  Resolved: 14/May/21

Status: Closed
Project: Java Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 4.3.0

Type: Bug Priority: Unknown
Reporter: Sk Iv Assignee: Ross Lawley
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by JAVA-4209 Add support for void types in Pojo's Closed

 Description   

Classes that have a static method that follows the bean convention cause a NPE.

For example:

public static void getStringField$Annotations() {
    // Mimics the static kotlin synthetic annotations field
} 

 

An example where this can automatically occur is when using annotations in Kotlin on non data classes.

 


Was: NPE in PojoBuilderHelper class for object with custom annotation

Hi I have a project (Kotlin + Spring Boot Data) which fails with null pointer exception when upsert is happening.
I've prepared test project to reproduce the issue: https://github.com/Skiv1989/spring-data-mongo-test

If you run the project it will try to store TestDto class, the class has an field with @SearchCriteria annotation. If I got correctly pojo converter thinks that annotation is a class field and trying to map it, which leads to NPE

Can you check please or advise how to avoid such exception?

As temporary solution I've made copy of dto classes, but without annotations and then maps dto to dom before store, but classes are absolutely same, so I want to avoid this duplication.



 Comments   
Comment by Githook User [ 12/May/21 ]

Author:

{'name': 'Ross Lawley', 'email': 'ross.lawley@gmail.com', 'username': 'rozza'}

Message: Fix NPE in PojoBuilderHelper where static methods follow bean convention

JAVA-4119
Branch: master
https://github.com/mongodb/mongo-java-driver/commit/3c0f582a58ae4a1ab3d7df631de118b36d68fa07

Comment by Ross Lawley [ 11/May/21 ]

https://github.com/mongodb/mongo-java-driver/pull/706

Comment by Esha Bhargava [ 27/Apr/21 ]

iskvort@gmail.com Thank you for reporting this issue. We'll look into it and get back to you soon.

Generated at Thu Feb 08 09:01:16 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.