Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.0.8
-
None
-
None
Description
I have this subroutine in some code managing DynamoDB tables; the types are from the Amazon 2 SDK and Vavr. The Either#fold method takes a Function<? super L, ? extends U> and a Function<? super R, ? extends U> (collapsing either a "left" or a "right" value into a single result). In this particular case, both types are the same DynamoDbTable, just representing different process states. The result type is a Try<DynamoDbTable>.
Aside from needing the workarounds that I think are related to GROOVY-10033 (.& and as CheckedRunnable), this code works as expected in GRECLIPSE, but it fails when compiled with groovyc.
private Try<DynamoDbTable> waitForTableActive(Either<DynamoDbTable, DynamoDbTable> maybeActive) { maybeActive.fold( Try.&success, // we already determined it's active table -> { log.debug('waiting for table {} to become active', table.tableName()) Try.success(table) .andThenTry({ poll.until { checkActive(table).isLeft() } } as CheckedRunnable) } ) } Either<DynamoDbTable, DynamoDbTable> checkActive(DynamoDbTable table) {}
Failed to execute goal org.codehaus.gmavenplus:gmavenplus-plugin:1.10.0:compile (default) on project azimuth-server: Error occurred while calling a method on a Groovy class from classpath.: InvocationTargetException: startup failed: DynamoDbSchemaRegistryImpl.groovy: 134: [Static type checking] - Cannot find matching method io.vavr.control.Try#tableName(). Please check if the declared type is correct and if the method exists. @ line 134, column 68. r table {} to become active', table.tabl ^ DynamoDbSchemaRegistryImpl.groovy: 136: [Static type checking] - Cannot find matching method co.vendorflow.azimuth.server.infrastructure.data.dynamodb.DynamoDbSchemaRegistryImpl#checkActive(io.vavr.control.Try <T>). Please check if the declared type is correct and if the method exists. @ line 136, column 59. Try({ poll.until { checkActive(table).is ^ DynamoDbSchemaRegistryImpl.groovy: 136: [Static type checking] - Cannot find matching method java.lang.Object#isLeft(). Please check if the declared type is correct and if the method exists. @ line 136, column 48. .andThenTry({ poll.until { checkActiv ^ DynamoDbSchemaRegistryImpl.groovy: 131: [Static type checking] - Cannot call <U> io.vavr.control.Either <DynamoDbTable, DynamoDbTable>#fold(java.util.function.Function <? super software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable, ? extends U>, java.util.function.Function <? super software.amazon.awssdk.enhanced.dynamodb.DynamoDbTable, ? extends U>) with arguments [groovy.lang.Closure <io.vavr.control.Try>, groovy.lang.Closure] @ line 131, column 9. maybeActive.fold( ^
I have absolutely no idea how the STC gets the idea that the parameter of the outer closure should be a Try (the result should be), and it seems possible that the rest of the errors are a cascade from that initial mistake.
Adding an explicit (DynamoDbTable table) -> gets groovyc to compile it, but then I still need to say as Function everywhere or I get complaints that "closure is not a function".