Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix null pointer exception in getProperty

  • Loading branch information...
commit 4e6b02e2a3084cb98c4d43bd7d8def1746e352e7 1 parent ccb39ea
@fabiooshiro authored
View
2  PlasticCriteriaGrailsPlugin.groovy
@@ -1,5 +1,5 @@
class PlasticCriteriaGrailsPlugin {
- def version = "1.4"
+ def version = "1.4.1"
def grailsVersion = "1.3 > *"
def pluginExcludes = [
'grails-app/domain/**',
View
1  grails-app/domain/plastic/criteria/Portrait.groovy
@@ -20,5 +20,6 @@ class Portrait {
color nullable: true
value nullable: true
lastSoldPrice nullable: true
+ artist nullable: true
}
}
View
44 src/groovy/plastic/criteria/CriteriaDocTests.groovy
@@ -370,7 +370,7 @@ class CriteriaDocTests {
assert ['Andreas Achenbach', 'Botero', 'Constance Gordon-Cumming'] == artistList
}
- //next release 0.5
+ // version 0.5
void testDistinctWithArrayParam() {
def b = new Artist(name: 'Tomie Oshiro').save()
new Portrait(artist: b, color: 'Ame', name: 'Cat').save() // Ame == yellow
@@ -425,7 +425,7 @@ class CriteriaDocTests {
assert [[monet, 1.1]] == rs
}
- // next release 0.6
+ // version 0.6
void test_fetch_mode() {
def monet = new Artist(name: 'Monet').save()
new Portrait(artist: monet, name: 'Soleil levant 1').save()
@@ -484,7 +484,7 @@ class CriteriaDocTests {
assert 'Japanese Bridge' == rs[0].bestPlace.name
}
- // next release 0.7
+ // version 0.7
void test_list_params_max() {
def monet = new Artist(name: 'Monet').save()
new Portrait(artist: monet, name: 'Soleil levant 1').save()
@@ -544,7 +544,7 @@ class CriteriaDocTests {
assert 'Soleil levant 1' == rs[2].name
}
- // next release 0.8
+ // version 0.8
void test_bug_list_size_smaller_than_max_results() {
def monet = new Artist(name: 'Monet').save()
new Portrait(artist: monet, name: 'Soleil levant 2').save()
@@ -586,7 +586,7 @@ class CriteriaDocTests {
assert 0 == rs.size()
}
- // next release 0.9
+ // version 0.9
void test_nested_object() {
def paris = new City(name: 'Paris').save()
def monet = new Artist(name: 'Monet', city: paris).save()
@@ -612,14 +612,14 @@ class CriteriaDocTests {
assert ['Autorretrato Com Mulata', 'Paisagem de Brodowski', 'Retirantes'] == rs.name
}
- // next release 1.0
+ // version 1.0
void test_bugfix_Negative_array_index_too_large_for_array_size_0() {
Portrait.createCriteria().get {
maxResults(1)
}
}
- // next release 1.2
+ // version 1.2
void test_createAlias() {
def paris = new City(name: 'Paris').save()
def monet = new Artist(name: 'Monet', city: paris).save()
@@ -642,7 +642,7 @@ class CriteriaDocTests {
assert ['Autorretrato Com Mulata', 'Paisagem de Brodowski', 'Retirantes'] == rs.name
}
- // next release 1.3
+ // version 1.3
void test_avg_division_undefined() {
def artitst = new Artist(name: 'Brilhante').save()
new Portrait(artist: artitst, name: 'Soleil levant', value: 1.0).save()
@@ -657,7 +657,7 @@ class CriteriaDocTests {
assert null == average
}
- // next release 1.4
+ // version 1.4
void test_setReadOnly() {
def artitst = new Artist(name: 'Brilhante').save()
new Portrait(artist: artitst, name: 'Soleil levant', value: 1.0).save()
@@ -669,4 +669,30 @@ class CriteriaDocTests {
assert 3 == list.size()
}
+ // version 1.4.1
+ void test_fix_null_pointer_in_getProperty() {
+ def monet = null
+ new Portrait(artist: monet, name: 'Soleil levant 1').save()
+
+ def rio = new City(name: 'Rio de Janeiro').save()
+ def portinari = new Artist(name: 'Portinari', city: rio).save()
+ new Portrait(artist: portinari, name: 'Retirantes').save()
+ new Portrait(artist: portinari, name: 'Paisagem de Brodowski').save()
+
+ def diCavalcanti = new Artist(name: 'Di Cavalcanti', city: rio).save()
+ new Portrait(artist: diCavalcanti, name: 'Autorretrato Com Mulata').save()
+
+ assert 4 == Portrait.count()
+ def rs = Portrait.withCriteria {
+ artist {
+ city {
+ eq('name', 'Rio de Janeiro')
+ }
+ }
+ order('name', 'asc')
+ }
+ assert 3 == rs.size()
+ assert ['Autorretrato Com Mulata', 'Paisagem de Brodowski', 'Retirantes'] == rs.name
+ }
+
}
View
11 src/groovy/plastic/criteria/PlasticCriteria.groovy
@@ -294,14 +294,15 @@ class PlasticCriteria {
def __getProperty(obj, propertyName){
def res = obj
def currentPath = []
- propertyName.split('\\.').each{
+ propertyName.split('\\.').each {
currentPath << it
- if(it == 'class'){
+ if (res == null) return
+ if (it == 'class') {
res = res.class.name
- }else{
- try{
+ } else {
+ try {
res = res."$it"
- }catch(MissingPropertyException e){
+ } catch(MissingPropertyException e) {
res = res."${_propertyAlias[currentPath.join('.')]}"
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.