Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-11126

Null-safe Dereference fails after time

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 4.0.11, 4.0.12
    • 4.0.14
    • bytecode
    • None
    • Zulu Java 17.0.7, Amazon Linux 2023, Spring Boot 3.1.1

    Description

      I have a server-side app that works perfectly for a long time (18-24h) then suddenly starts throwing "impossible" errors.

      Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.CharSequence.length()" because "self" is null	
              at org.codehaus.groovy.runtime.StringGroovyMethods.size(StringGroovyMethods.java:2693)	at org.codehaus.groovy.runtime.dgm$1323.doMethodInvoke(Unknown Source)
      	at com.hatchbaby.model.ColorParser.isOneByteFormat(ColorParser.groovy:74)
      	at com.hatchbaby.model.ColorParser.getRed(ColorParser.groovy:13)
      	at com.hatchbaby.domain.Content.getRed(Content.groovy:173)
       

      The line of code at ColorParser:74 is:

      int size = color?.size() ?: 0 

      The variable `color` is a String. The null-safe dereference operator has ceased to short-circuit.

      This code is years old and has run flawlessly. Since the upgrade from Spring Boot 2.7.4 to Boot 3.1.1, it runs fine for 18-24h, then it starts throwing NullPointerExceptions.  This is happening at a couple of other places in the code, all on null-safe dereferences that don't short-circuit. The above code is hit 9,000+ times/day. We have a cluster of servers and they seem to develop the problem within a couple hours of each other.

      The server is running with Spring Boot 3.1.1 (hence Groovy 4.0.12) running on Java 17.0.7 (Azul Zulu) on Amazon Linux 2023. The project is joint Java and Groovy code that is compiled with the GMavenPlus 3.0.0 Maven plugin (maven 3.9.1)

      I have tried to reproduce the error by running a tiny program that mimics the error, but so far after running 1.4 million invocations over 24h with no errors (as you might expect).

      Attachments

        1. javapOutput2.txt
          60 kB
          Kenneth W DeLong
        2. javapOutput.txt
          54 kB
          Kenneth W DeLong

        Activity

          People

            emilles Eric Milles
            kenwdelong Kenneth W DeLong
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: