Could not run test java.lang.NullPointerException

941 views
Skip to first unread message

Dmitry Bushev

unread,
Jul 11, 2013, 9:18:28 AM7/11/13
to scalate...@googlegroups.com
Hi,

we are currently moving from TestNG to Scalatest and some of tests extends TestNGSuite and some uses Scalatest Suites, but maybe it's not related. There are quite a lot of tests and the problem is that sometimes (actually quite often, nearly every third build) they are randomly failing on build server with: [error] Could not run test ...: java.lang.NullPointerException. On local machine it's always fine. I've managed to reproduce this issue locally only by running tests in loop on ~50'th run. So, I think it's somehow concurrency related.

Using latest 2.0.M6-SNAP26
Any help appreciated.

[15:01:09]java.lang.NullPointerException
[15:01:09] at org.scalatest.tools.ScalaTestFramework$RunConfig$.decreaseLatch(ScalaTestFramework.scala:176)
[15:01:09] at org.scalatest.tools.ScalaTestFramework$ScalaTestRunner.run(ScalaTestFramework.scala:336)
[15:01:09] at org.scalatools.testing.Runner2.run(Runner2.java:16)
[15:01:09] at sbt.TestRunner.delegateRun(TestFramework.scala:57)
[15:01:09] at sbt.TestRunner.run(TestFramework.scala:51)
[15:01:09] at sbt.TestRunner.runTest$1(TestFramework.scala:71)
[15:01:09] at sbt.TestRunner.run(TestFramework.scala:80)
[15:01:09] at sbt.TestFramework$$anonfun$9$$anonfun$apply$9$$anonfun$10$$anonfun$apply$10.apply(TestFramework.scala:188)
[15:01:09] at sbt.TestFramework$$anonfun$9$$anonfun$apply$9$$anonfun$10$$anonfun$apply$10.apply(TestFramework.scala:188)
[15:01:09] at sbt.TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:200)
[15:01:09] at sbt.TestFramework$$anonfun$9$$anonfun$apply$9$$anonfun$10.apply(TestFramework.scala:188)
[15:01:09] at sbt.TestFramework$$anonfun$9$$anonfun$apply$9$$anonfun$10.apply(TestFramework.scala:188)
[15:01:09] at sbt.Tests$$anonfun$makeParallel$1$$anonfun$apply$7.apply(Tests.scala:119)
[15:01:09] at sbt.Tests$$anonfun$makeParallel$1$$anonfun$apply$7.apply(Tests.scala:119)
[15:01:09] at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:47)
[15:01:09] at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:47)
[15:01:09] at sbt.std.Transform$$anon$5.work(System.scala:71)
[15:01:09] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
[15:01:09] at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)
[15:01:09] at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
[15:01:09] at sbt.Execute.work(Execute.scala:238)
[15:01:09] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
[15:01:09] at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:232)
[15:01:09] at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
[15:01:09] at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
[15:01:09] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[15:01:09] at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[15:01:09] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:439)
[15:01:09] at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
[15:01:09] at java.util.concurrent.FutureTask.run(FutureTask.java:138)
[15:01:09] at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
[15:01:09] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
[15:01:09] at java.lang.Thread.run(Thread.java:662)
[15:01:09][error] Could not run test ...: java.lang.NullPointerException

Bill Venners

unread,
Jul 11, 2013, 11:30:09 AM7/11/13
to scalate...@googlegroups.com
Hi Dmitry,

Yes I suspect there's a race condition with some vars that are initialized to null. When I came across these in the code a while back I add the comment:

// TODO: Ack, cockroaches! I mean vars. Refactor to vals.
    private var reporter: DispatchReporter = null

But we didn't do that yet, as we were focusing on our implementation of the new Framework API. I'll talk to Chee Seng about this tonight, but one thing you could try if you're brave is sbt 0.13.0-RC1, which will use our implementation of the new Framework API instead. This would be a good exercise for sbt 0.13.0 and our new Framework API implementation, and might solve your problem already.

Bill



--
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Bill Venners
Artima, Inc.
http://www.artima.com

Dmitry Bushev

unread,
Jul 11, 2013, 12:15:30 PM7/11/13
to scalate...@googlegroups.com
Hi Bill,

Thanks for a quick answer. Unfortunately, I can't move project to SBT release candidate right now, mainly because of plugins, and in general it will be quite painful. Do you have any estimated dates for 0.13 release?

p.s. sorry for bad formatting, didn't notice.

Charles Feduke

unread,
Jul 17, 2013, 9:41:34 PM7/17/13
to scalate...@googlegroups.com
I am encountering this same stack trace, though reproducible 100% of the time when running my tests via test:test through sbt.

On the console ValidationUnitSpec passes first, then all tests contained in RoutingServiceUnitSpec pass second, and finally RoutingServiceUnitSpec is marked as failed due to what I have surmised to be a null reporter instance (ScalaTestFramework.scala:149 in 2.0.M6-SNAP9):

[debug] Running Test company.project.specs.unit.RoutingServiceUnitSpec : subclass(false, org.scalatest.Suite) with arguments 
[debug] Running Test company.project.specs.unit.validations.ValidatorUnitSpec : subclass(false, org.scalatest.Suite) with arguments 
java.lang.NullPointerException
at org.scalatest.tools.ScalaTestFramework$RunConfig$.decreaseLatch(ScalaTestFramework.scala:149)
at org.scalatest.tools.ScalaTestFramework$ScalaTestRunner.run(ScalaTestFramework.scala:297)
at org.scalatools.testing.Runner2.run(Runner2.java:16)
at sbt.TestRunner.delegateRun(TestFramework.scala:57)
at sbt.TestRunner.run(TestFramework.scala:51)
at sbt.TestRunner.runTest$1(TestFramework.scala:71)
at sbt.TestRunner.run(TestFramework.scala:80)
        ...

Running test:test-only company.projects.specs.unit.RoutingServiceUnitSpec passes.

The two test suites do not contain any shared state.

(I will also update to a later SNAP as I'm clearly woefully behind.)

I cannot bump our sbt version from 0.12.x due to an existing plugin infrastructure.

Charles Feduke

unread,
Jul 17, 2013, 9:45:56 PM7/17/13
to scalate...@googlegroups.com
Posted too soon, bumped to SNAP30 and test:test now runs correctly.

Bill Venners

unread,
Jul 17, 2013, 9:48:39 PM7/17/13
to scalate...@googlegroups.com
Hi Charles and Dmitry,

Yes, sorry we got rid of those vars (made a satisfying crunching sound) but I forgot to mention the new SNAP here. SNAP30 has the change. We were unable to reproduce the problem you were seeing before or after the fix, which means I'm not 100% sure it is solved for real. So please let us know if you still see any issues.

https://oss.sonatype.org/content/groups/public/org/scalatest/scalatest_2.10/2.0.M6-SNAP30/

Thanks.

Bill

Dmitry Bushev

unread,
Jul 30, 2013, 10:05:20 AM7/30/13
to scalate...@googlegroups.com
Hi Bill,

Running tests with SNAP30 for several days without any errors. Thanks for your help!
Reply all
Reply to author
Forward
0 new messages