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

fix(core): A runtime NullPointerException when extractValues is called with null property #16

Conversation

humberthardy
Copy link
Contributor

@humberthardy humberthardy commented Aug 10, 2022

Fix a runtime NullPointerException when extractValues is called with null property.

How to Reproduce

(this is a simplified version of the code, I hope it works):

Define a Gorm model like this

class Category() {
  int id 
  String name
  static mappedBy = [children: "children"]

   List <Category> children {
     def c = CategoryRelation.createCriteria()
     def ids = c.list( eq (b, id) )
     return this.createCriteria().list(in ('id', ids)
  }

}

class CategoryRelation() {
a Category,
b Category
  static mapping = {
    id composite: [a, b]
  }
}
def parent = new Category(name: "parent").save()
def child = new Category(name: "Child").save()
def relation = new CategoryRelation(a: parent, b: child).save()
>>> parent as JSON

In this case, it will call DomainClassMarshaller.asShortObject(_, _, referencedIdProperty *<= null*, CategoryRelation)

@puneetbehl puneetbehl changed the base branch from master to 5.0.x February 26, 2024 07:08
@puneetbehl puneetbehl force-pushed the fix-gorm-nested-object-with-composite-key branch from 21c8a2b to 846f691 Compare February 26, 2024 07:08
@puneetbehl puneetbehl changed the title Fix a runtime NullPointerException when extractValues is called with null property. fix: A runtime NullPointerException when extractValues is called with null property Feb 26, 2024
@puneetbehl puneetbehl changed the title fix: A runtime NullPointerException when extractValues is called with null property fix(core): A runtime NullPointerException when extractValues is called with null property Feb 26, 2024
@puneetbehl puneetbehl merged commit fd69d18 into grails:5.0.x Feb 26, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

None yet

2 participants