Skip to content

Commit

Permalink
Patch unpexpected error on tower serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
pditommaso committed Sep 26, 2020
1 parent 294798f commit f922324
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,32 @@ class TowerJsonGenerator extends DefaultJsonGenerator {
protected void writeObject(String key, Object object, CharBuf buffer) {
final pos=stack.size()
if(key) stack.add(pos, key)
final fqn = stack.join('.')
try {
final fqn = stack.join('.')
if( fqn == 'workflow.manifest.gitmodules' && object instanceof List ) {
writeCharSequence(object.join(','), buffer)
}
else
super.writeObject(key,object,buffer)
}
catch( Exception e ) {
log.warn1 ("Unable to serialize key=$fqn; value=${safeString0(object)}; type=${object?.getClass()?.getName()} -- Cause: ${e.message ?: e}", causedBy: e)
}
finally {
if(key) stack.remove(pos)
}
}

private String safeString0(Object obj) {
try {
return obj !=null ? obj.toString() : null
}
catch( Throwable e ) {
log.debug "SafeString error=${e.message ?: e}"
return null
}
}

@Override
protected void writeRaw(CharSequence seq, CharBuf buffer) {
super.writeRaw(chompString(seq),buffer)
Expand Down

0 comments on commit f922324

Please sign in to comment.