Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

slow validation caused by string replaceAll to remove nulls #120

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package nextflow.validation

import groovy.json.JsonBuilder
import groovy.json.JsonSlurper
import groovy.json.JsonGenerator
import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import groovyx.gpars.dataflow.DataflowWriteChannel
Expand Down Expand Up @@ -531,14 +532,12 @@ class SchemaValidator extends PluginExtensionPoint {
.build()
final schema = schemaLoader.load().build()

// Convert the groovy object to a JSONArray
def jsonObj = new JsonBuilder(fileContent)
// Remove all null values from JSON object
jsonObj = jsonObj.toString()
while (jsonObj.contains("null")) {
jsonObj = jsonObj.replaceAll("(.*)(\".*?\":null,?)", '$1')
}
def JSONArray arrayJSON = new JSONArray(jsonObj)
// and convert the groovy object to a JSONArray
def jsonGenerator = new JsonGenerator.Options()
.excludeNulls()
.build()
def JSONArray arrayJSON = new JSONArray(jsonGenerator.toJson(fileContent))

//=====================================================================//
// Check for params with expected values
Expand Down