[JIRA] (JENKINS-44587) writeJSON throws java.lang.UnsupportedOperationException: must specify $class with an implementation of interface net.sf.json.JSON

20 views
Skip to first unread message

ianfixes@gmail.com (JIRA)

unread,
Dec 5, 2019, 10:02:04 PM12/5/19
to jenkinsc...@googlegroups.com
Ian Katz commented on Bug JENKINS-44587
 
Re: writeJSON throws java.lang.UnsupportedOperationException: must specify $class with an implementation of interface net.sf.json.JSON

The resolution of this bug is "fixed", but I'm seeing this problem on Jenkins 2.190.2.  Does that indicate a regression, or was the "fix" here to just use the workaround?

I would have expected that the implementation of writeJSON would do the following

// given a mapLikeObject containing data, and an outputPath

try {
  writeJSON file: outputPath, json: mapLikeObject, pretty: 2
} catch (java.lang.UnsupportedOperationException e) {
  def jsonOut = readJSON text: groovy.json.JsonOutput.toJson(mapLikeObject)
  writeJSON file: outputPath, json: jsonOut, pretty: 2
}

i.e. falling back on conversion to string and back in cases where an incompatible object is passed to writeJSON.  

 

Should this bug be reopened or should I file a new one?

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages