Pattern selector

Most relevant patterns first. Most helpful ones displayed. Click here to show all.

  1. Thread.run() has thrown a ServletException
    Java Runtime
    0
    0
    0
  2. NullPointerException thrown on NullObject
    Apache Groovy
    34
    85
    38

Your stack trace compared to the selected pattern

Jump to solutionsExpand frames
java.lang.NullPointerException: Cannot invoke method isEmpty() on null object
    at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:91)
    at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:48)
    at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
    at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:35)
70 frames hidden

Solution

Mohd Salauddin3 months ago

NullObject.invokeMethod() has thrown a NullPointerException This is the exception from NullObject Class in Groovy. Whenever we call any method in groovy on null object , we get "Cannot invoke method " name of th method " on null object"

whenenver we reference any object in groovy to null ( def sampleObject = null ) , it becomes the object of NullObject Class and if we try to call any method on that (sampleObject), groovy will call invokeMethod() method on null object and thows NullPointerException

One Simple Solution to this is , using ?, For Example , sampleObject?.methodName() ; This is will not throw NullPointerException , It only calls method, if the object is not null.

External results for this pattern (10)

  1. onusgitvia GitHub2 days ago
    Failed to capture snapshot of input files for task ':react-native-push-notification:compileDebugAidl' property 'importDirs' during up-to-date check.
    Show stack trace
  2. Eric Hovia Google Groups1 week ago
    Cannot invoke method getAt() on null object
    Show stack trace
  3. Steve Storckvia Google Groups1 week ago
    Cannot invoke method getBean() on null object
    Show stack trace
  4. Laurent Kempévia Google Groups1 week ago
    Cannot invoke method getName() on null object
    Show stack trace
  5. seilc1via GitHub2 weeks ago
    Cannot invoke method size() on null object
    Show stack trace
  6. smartbinbinvia GitHub1 month ago
    A problem occurred configuring project ':library'.
    Show stack trace
  7. wkingvia GitHub1 month ago
    Cannot invoke method isInQueue() on null object
    Show stack trace
  8. mrkhanakiavia GitHub1 month ago
    Failed to capture snapshot of input files for task ':react-native-device-info:compileDebugAidl' property 'importDirs' during up-to-date check.
    Show stack trace
  9. schwichtivia GitHub1 month ago
    java.lang.NullPointerException: Cannot invoke method inE() on null object
    Show stack trace
  10. greenkiwivia GitHub1 month ago
    Cannot invoke method supportsMinimalClusters() on null object
    Show stack trace