-
Notifications
You must be signed in to change notification settings - Fork 193
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
STC: NullPointerException
for raw type guard followed by parameterized method call
#1349
Comments
You can debug your eclipse process by adding this to eclipse.ini:
Then you can connect from any new java workspace using a Remote Java Application launch config set to port 5005. From there just add exception breakpoint for NullPointerException to get a stack in the Debug perspective. |
Here it is:
|
Thanks. You can also back up the stack and see what file and what part of this file has the issue. The |
The
That method source is: void cleanEmptyValues(Object... beans) {
if(beans)
beans.each { bean ->
if(bean)
bean.properties.each { key, value ->
if(value instanceof IdentifiableDto || value instanceof ModelObject)
cleanEmptyValues(value)
else if(value instanceof Iterable)
value.each { cleanEmptyValues(it) }
else if(value instanceof String && value.toString().trim() == '')
bean[(String) key] = null
}
}
} |
Can you try casting "it" to |
Unfortunately, adding that cast doesn't make any difference. The exception is the same, as well as the involved |
I can make the problem go away if I change both recursive void cleanEmptyValues(Object... beans) {
if(beans)
beans.each { bean ->
if(bean)
bean.properties.each { key, value ->
if(value instanceof IdentifiableDto || value instanceof ModelObject)
cleanEmptyValues([value])
else if(value instanceof Iterable)
value.each { cleanEmptyValues([it]) }
else if(value instanceof String && value.toString().trim() == '')
bean[(String) key] = null
}
}
} |
Sorry, I meant to say cast "value" since that is what was tested against Iterable: |
I have to cast both |
The issue starts because the extension method Two typecasts have been inserted below that should get rid of the raw-type funging: void cleanEmptyValues(Object... beans) {
beans?.each { bean ->
if (bean) ((Map<String,Object>)bean.properties).each { key, value ->
if (value instanceof IdentifiableDto || value instanceof ModelObject)
cleanEmptyValues(value)
else if (value instanceof Iterable)
((Iterable<Object>)value).each { cleanEmptyValues(it) }
else if (value instanceof String && value.trim().isEmpty())
bean[key] = null
}
}
} https://issues.apache.org/jira/browse/GROOVY-10527 |
NullPointerException
for raw type guard followed by parameterized method call
GROOVY-9968, GROOVY-10327, GROOVY-10528
I confirm this does not happen any more with 4.6.0.v202204021925-e2112. |
Using Greclipse 4.5.0.v202203070924-e2112.
Using Groovy 2.5.16 in my project build path.
One of my projects has started to fail Groovy compilation within Eclipse with this error:
On the groovy console I find this:
This is a huge proprietary project, so I have no idea on how to cut it down. Is there something I can share with you to understand what's wrong? Maybe the contents of the affected class?
It seems like removing
@CompileStatic
from this class and issue a full project rebuild fixes the error.This same project compiles fine with Gradle.
The text was updated successfully, but these errors were encountered: