question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Regression in Groovy: ClassCastException for closures not returning Boolean

See original GitHub issue

Code:

Awaitility.await().until({ "something" })

1.7.0: passes 2.0.0: fails with

java.lang.String cannot be cast to java.lang.Boolean
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Boolean
	at org.awaitility.core.CallableCondition$ConditionEvaluationWrapper.eval(CallableCondition.java:100)
	at org.awaitility.core.ConditionAwaiter$ConditionPoller.run(ConditionAwaiter.java:215)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
	at java.util.concurrent.FutureTask.run(FutureTask.java:262)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
	at java.lang.Thread.run(Thread.java:745)

AwaitilityGroovyBridge used runnable as Callable<Boolean> while AwaitilityExtensionModule uses runnable as Callable.

Implementing AwaitilityTrait does not help, it seems that the extension module takes precedence. You need to change the closure to { "something" != null }.

Release Notes don’t mention any breaking changes, so I consider this as a regression.

Also, please update examples from https://github.com/awaitility/awaitility/wiki/Groovy - they use deprecated classes.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
pkubowiczcommented, Jan 23, 2017

I don’t see any problems with the current snapshot - I am closing this issue.

0reactions
pkubowiczcommented, Jan 18, 2017

I found some problems if you had AwaitilityTrait in your code. My fixes in #73.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why is this Groovy closure not returning the value that I expect?
The each method returns the same collection it was invoked on, so retVal is probably not the boolean "true", but is evaluated as...
Read more >
Unable to use until(Runnable) with Clousure if awaitility ...
With awaitility-groovy module on a classpath it is not possible to use unitl(Runnable) with Groovy Closure, e.g..
Read more >
Changelog for Groovy 1.1.0-unreleased
[GROOVY-1186] - NullpointerException occurs when unboxing boolean Java return type where no return value specified from Java interface implemented in Groovy ...
Read more >
Changelog for Groovy 1.7.0
Properties unless getProperty() is overridden; [GROOVY-2583] - "object is not an instance of declaring class" thrown invoking a method on Groovy class, ...
Read more >
Changelog for Groovy 4.0.0
[GROOVY-6097] - Using super.propertyName gives a MissingMethodException when the property is a boolean and uses the "isPropertyName" naming convention. [GROOVY- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found