Deprecated APIs in Groovy 3

In the upcoming 4.25.1.0.0 release, we will upgrade the Groovy library from 3.x to 4.x. Several APIs have been deprecated in Groovy 3 and are removed in Groovy 4. See Groovy 3.0 Release Notes for more information.

The change applies to all Oracle Health Insurance components. Date of deprecation: 2024-08-30.

What is Deprecated?

In Groovy 3, duplicate versions of several classes were provided in legacy packages to ease migration, but Groovy 4 removes these legacy classes. For example, classes previously available in both groovy.util and groovy.xml (such as XmlSlurper and XmlParser) are now available only in the groovy.xml package in Groovy 4. Therefore, customers who use classes from groovy.util must update their dynamic logic to use groovy.xml instead to ensure compatibility with Groovy 4.

Actions for the Customer to Take

Customers must update any dynamic logic that uses deprecated classes to maintain compatibility.

Migration Details for groovy.util Classes

The following classes have been deprecated in groovy.util package in Groovy 3.x and are removed from groovy.util package in Groovy 4.x. Update your dynamic logic to import these classes from groovy.xml instead:

  • groovy.util.XmlNodePrinter

  • groovy.util.XmlParser

  • groovy.util.XmlSlurper

  • groovy.util.XmlUtil

  • groovy.util.slurpersupport.Attribute

  • groovy.util.slurpersupport.Attributes

  • groovy.util.slurpersupport.FilteredAttributes

  • groovy.util.slurpersupport.FilteredNodeChildren

  • groovy.util.slurpersupport.GPathResult

  • groovy.util.slurpersupport.NamespaceAwareHashMap

  • groovy.util.slurpersupport.NoChildren

In Groovy 3, classes from groovy.util were automatically imported. With Groovy 4, these classes in groovy.xml require explicit import statements. To avoid errors, ensure you add the necessary imports.

To help identify dynamic logic scripts that require modification, use the following POST request:

http://[hostName]:[portNumber]/[api-context-root]/generic/dynamiclogic/search

{
    "resource": {
        "q": "logic.like('%XmlNodePrinter%').or.logic.like('%XmlParser%').or.logic.like('%XmlSlurper%').or.logic.like('%XmlUtil%').or.logic.like('%groovy.util.slurpersupport%')"
    }
}

Code Migration Examples

The following examples show how to update code for compatibility with Groovy 4.

Example 1: Using XmlSlurper Without Import

Current dynamic logic: Uses XmlSlurper without an explicit import (implicitly relying on groovy.util):

def result = new XmlSlurper().parseText(response)

Updated dynamic logic: Add an explicit import for groovy.xml.XmlSlurper:

import groovy.xml.XmlSlurper

def result = new XmlSlurper().parseText(response)

Or use the fully qualified name:

def result = new groovy.xml.XmlSlurper().parseText(response)

Example 2: Explicitly Importing groovy.util.XmlSlurper

Current dynamic logic: Imports groovy.util.XmlSlurper explicitly:

import groovy.util.XmlSlurper

def result = new XmlSlurper().parseText(response)

Updated dynamic logic: Update the import to groovy.xml.XmlSlurper:

import groovy.xml.XmlSlurper

def result = new XmlSlurper().parseText(response)

Example 3: Correct Use of groovy.xml.XmlSlurper

Current dynamic logic: Already imports groovy.xml.XmlSlurper, so no changes are needed:

import groovy.xml.XmlSlurper

def result = new XmlSlurper().parseText(response)