[JIRA] [pipeline-milestone-step-plugin] (JENKINS-35444) java.io.NotSerializableException issues even with @NonCPS

1,055 views
Skip to first unread message

trevorhartman@gmail.com (JIRA)

unread,
Jun 7, 2016, 5:54:01 PM6/7/16
to jenkinsc...@googlegroups.com
Trevor Hartman created an issue
 
Jenkins / Bug JENKINS-35444
java.io.NotSerializableException issues even with @NonCPS
Issue Type: Bug Bug
Assignee: Antonio Muñiz
Components: pipeline-milestone-step-plugin
Created: 2016/Jun/07 9:53 PM
Priority: Minor Minor
Reporter: Trevor Hartman

I get java.io.NotSerializableException: java.util.regex.Matcher on:

Unable to find source-code formatter for language: groovy. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
@NonCPS
def extractLatency(linesArr) {
  latency = [:]
  println "extractLatency"
  for (int j = 0; j < linesArr.size(); j++) {
    line = linesArr[j]
    println("looping over line: $line")
    // Matches lines like: Connect:        0    1   0.1      1       1
    abPattern = /(\w+)\:\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)/

    def matcher = { (line =~ abPattern) }

    if (matcher().size > 1) {
      println("matched")
    }

    matcher = null
    abPattern = null
  }
  return latency
}

If I throw a @NonCPS on the inner `def matcher` it fixes it.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.2#64017-sha1:e244265)
Atlassian logo

andrew.bayer@gmail.com (JIRA)

unread,
Jun 7, 2016, 5:55:02 PM6/7/16
to jenkinsc...@googlegroups.com
Andrew Bayer assigned an issue to Andrew Bayer
Change By: Andrew Bayer
Assignee: Antonio Muñiz Andrew Bayer

trevorhartman@gmail.com (JIRA)

unread,
Jun 7, 2016, 5:55:03 PM6/7/16
to jenkinsc...@googlegroups.com
Trevor Hartman updated an issue
Change By: Trevor Hartman
I get java.io.NotSerializableException: java.util.regex.Matcher on:

{code: groovy java }

@NonCPS
def extractLatency(linesArr) {
  latency = [:]
  println "extractLatency"
  for (int j = 0; j < linesArr.size(); j++) {
    line = linesArr[j]
    println("looping over line: $line")
    // Matches lines like: Connect:        0    1   0.1      1       1
    abPattern = /(\w+)\:\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)/

    def matcher = { (line =~ abPattern) }

    if (matcher().size > 1) {
      println("matched")
    }

    matcher = null
    abPattern = null
  }
  return latency
}
{code}


If I throw a @NonCPS on the inner `def matcher` it fixes it.

andrew.bayer@gmail.com (JIRA)

unread,
Jun 7, 2016, 5:55:03 PM6/7/16
to jenkinsc...@googlegroups.com
Andrew Bayer updated an issue
Change By: Andrew Bayer
Component/s: workflow-plugin
Component/s: pipeline-milestone-step-plugin
I get java.io.NotSerializableException: java.util.regex.Matcher on:

{code: java groovy }

@NonCPS
def extractLatency(linesArr) {
  latency = [:]
  println "extractLatency"
  for (int j = 0; j < linesArr.size(); j++) {
    line = linesArr[j]
    println("looping over line: $line")
    // Matches lines like: Connect:        0    1   0.1      1       1
    abPattern = /(\w+)\:\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)/

    def matcher = { (line =~ abPattern) }

    if (matcher().size > 1) {
      println("matched")
    }

    matcher = null
    abPattern = null
  }
  return latency
}
{code}

If I throw a @NonCPS on the inner `def matcher` it fixes it.

jglick@cloudbees.com (JIRA)

unread,
Jun 9, 2016, 2:47:01 PM6/9/16
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
Change By: Jesse Glick
I get  {{  java.io.NotSerializableException: java.util.regex.Matcher }}  on:

{code
:groovy }

@NonCPS
def extractLatency(linesArr) {
  latency = [:]
  println "extractLatency"
  for (int j = 0; j < linesArr.size(); j++) {
    line = linesArr[j]
    println("looping over line: $line")
    // Matches lines like: Connect:        0    1   0.1      1       1
    abPattern = /(\w+)\:\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)/

    def matcher = { (line =~ abPattern) }

    if (matcher().size > 1) {
      println("matched")
    }

    matcher = null
    abPattern = null
  }
  return latency
}
{code}

If I throw a @NonCPS on the inner `def matcher` it fixes it.

jglick@cloudbees.com (JIRA)

unread,
Jun 9, 2016, 2:47:02 PM6/9/16
to jenkinsc...@googlegroups.com
Jesse Glick updated an issue
I get {{java.io.NotSerializableException: java.util.regex.Matcher}} on:

{code}
@NonCPS
def extractLatency(linesArr) {
  latency = [:]
  println "extractLatency"
  for (int j = 0; j < linesArr.size(); j++) {
    line = linesArr[j]
    println("looping over line: $line")
    // Matches lines like: Connect:        0    1   0.1      1       1
    abPattern = /(\w+)\:\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)\s+(\d+\.?\d*)/

    def matcher = { (line =~ abPattern) }

    if (matcher().size > 1) {
      println("matched")
    }

    matcher = null
    abPattern = null
  }
  return latency
}
{code}

If I throw a
 {{  @NonCPS }}  on the inner  `  {{ def matcher ` }}  it fixes it.

jglick@cloudbees.com (JIRA)

unread,
Jun 9, 2016, 2:48:01 PM6/9/16
to jenkinsc...@googlegroups.com
Jesse Glick commented on Bug JENKINS-35444
 
Re: java.io.NotSerializableException issues even with @NonCPS

I assume this was a prototype on the way to a working function, since latency seems to be left empty, and matcher could simply be inlined.

Probably the issue is just that @NonCPS is not inherited lexically.

Reply all
Reply to author
Forward
0 new messages