Skip to content

Commit c7316ea

Browse files
committed
Fix NPE when params value is null
Signed-off-by: Paolo Di Tommaso <[email protected]>
1 parent 039ad40 commit c7316ea

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

modules/nf-lineage/src/main/nextflow/lineage/LinObserver.groovy

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,10 @@ class LinObserver implements TraceObserver {
175175

176176
protected static List<Parameter> getNormalizedParams(Map<String, Object> params, PathNormalizer normalizer){
177177
final normalizedParams = new LinkedList<Parameter>()
178-
params.each{ String key, Object value ->
179-
normalizedParams.add( new Parameter( getParameterType(value), key, normalizeValue(value, normalizer) ) )
178+
for( Map.Entry<String,Object> entry : params ) {
179+
final key = entry.key
180+
final val = entry.value
181+
normalizedParams.add( new Parameter( getParameterType(val), key, normalizeValue(val, normalizer) ) )
180182
}
181183
return normalizedParams
182184
}
@@ -220,7 +222,7 @@ class LinObserver implements TraceObserver {
220222

221223
private static Object normalizeValue(Object value, PathNormalizer normalizer) {
222224
if (value instanceof Path)
223-
return normalizer.normalizePath(value as Path)
225+
return normalizer.normalizePath((Path)value)
224226
else if (value instanceof CharSequence)
225227
return normalizer.normalizePath(value.toString())
226228
else
@@ -405,7 +407,9 @@ class LinObserver implements TraceObserver {
405407
return Collection.simpleName
406408
if( param instanceof Map)
407409
return Map.simpleName
408-
return param.class.simpleName
410+
return param!=null
411+
? param.class.simpleName
412+
: null
409413
}
410414

411415
private Object convertPathsToLidReferences(Object value){

modules/nf-lineage/src/test/nextflow/lineage/LinObserverTest.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,13 @@ class LinObserverTest extends Specification {
191191
folder?.deleteDir()
192192
}
193193

194+
@Unroll
194195
def 'should get parameter type' () {
195196
expect:
196197
LinObserver.getParameterType(PARAM) == STRING
197198
where:
198199
PARAM | STRING
200+
null | null
199201
new FileInParam(null, []) | "path"
200202
new ValueOutParam(null, []) | "val"
201203
new EnvOutParam(null, []) | "env"

0 commit comments

Comments
 (0)