chore(kork): fix compatibility with latest kork
MODIFY
build.gradle
build.gradle
@@ -18,7 +18,7 @@ allprojects {
apply plugin: 'groovy'
ext {
- spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.87.0'
+ spinnakerDependenciesVersion = project.hasProperty('spinnakerDependenciesVersion') ? project.property('spinnakerDependenciesVersion') : '0.89.0'
}
def checkLocalVersions = [spinnakerDependenciesVersion: spinnakerDependenciesVersion]

MODIFY
gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/commands/AbstractHystrixCommand.groovy
gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/commands/AbstractHystrixCommand.groovy
package com.netflix.spinnaker.gate.services.commands
+import java.util.concurrent.Callable
import com.netflix.hystrix.HystrixCommand
import com.netflix.hystrix.HystrixCommandKey
import com.netflix.spinnaker.gate.retrofit.UpstreamBadRequest
@@ -23,10 +24,8 @@ import groovy.transform.CompileStatic
import groovy.util.logging.Slf4j
import org.springframework.http.HttpStatus
import retrofit.RetrofitError
-
import static HystrixFactory.createHystrixCommandPropertiesSetter
import static HystrixFactory.toGroupKey
-import static retrofit.RetrofitError.Kind.HTTP
@Slf4j
@CompileStatic
@@ -35,13 +34,13 @@ abstract class AbstractHystrixCommand<T> extends HystrixCommand<T> {
private final String groupKey
private final String commandKey
- protected final Closure work
- protected final Closure fallback
+ protected final Callable<T> work
+ protected final Callable<T> fallback
public AbstractHystrixCommand(String groupKey,
String commandKey,
- Closure work,
- Closure fallback) {
+ Callable<T> work,
+ Callable<T> fallback) {
super(HystrixCommand.Setter.withGroupKey(toGroupKey(groupKey))
.andCommandKey(HystrixCommandKey.Factory.asKey(commandKey))
.andCommandPropertiesDefaults(createHystrixCommandPropertiesSetter()))
@@ -54,14 +53,14 @@ abstract class AbstractHystrixCommand<T> extends HystrixCommand<T> {
@Override
protected T run() throws Exception {
try {
- return work()
+ return work.call()
} catch (RetrofitError error) {
throw UpstreamBadRequest.classifyError(error, HttpStatus.values().findAll { it.is4xxClientError() }*.value() as Collection<Integer>)
}
}
protected T getFallback() {
- return (fallback.call() as T)
+ return fallback.call()
}
@Override

MODIFY
gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/commands/HystrixFactory.groovy
gate-core/src/main/groovy/com/netflix/spinnaker/gate/services/commands/HystrixFactory.groovy
package com.netflix.spinnaker.gate.services.commands
+import java.util.concurrent.Callable
import com.netflix.hystrix.HystrixCommandGroupKey
import com.netflix.hystrix.HystrixCommandProperties
import static com.netflix.spinnaker.security.AuthenticatedRequest.propagate
@@ -29,56 +30,56 @@ class HystrixFactory {
HystrixCommandGroupKey.Factory.asKey(name)
}
- public static ListCommand newListCommand(String groupKey,
+ public static <T> ListCommand newListCommand(String groupKey,
String commandKey,
- Closure<? extends List> work,
- Closure<? extends List> fallback = { null }) {
+ Callable<List<T>> work,
+ Callable<List<T>> fallback = { null }) {
new ListCommand(groupKey, commandKey, propagate(work, false), fallback)
}
- public static MapCommand newMapCommand(String groupKey,
+ public static <K, V> MapCommand<K, V> newMapCommand(String groupKey,
String commandKey,
- Closure<? extends Map> work,
- Closure<? extends Map> fallback = { null }) {
+ Callable<Map<K, V>> work,
+ Callable<Map<K, V>> fallback = { null }) {
new MapCommand(groupKey, commandKey, propagate(work, false), fallback)
}
public static StringCommand newStringCommand(String groupKey,
String commandKey,
- Closure<? extends String> work,
- Closure<? extends String> fallback = { null }) {
+ Callable<String> work,
+ Callable<String> fallback = { null }) {
new StringCommand(groupKey, commandKey, propagate(work, false), fallback )
}
public static VoidCommand newVoidCommand(String groupKey,
String commandKey,
- Closure<?> work,
- Closure<?> fallback = { null }) {
+ Callable<Void> work,
+ Callable<Void> fallback = { null }) {
new VoidCommand(groupKey, commandKey, propagate(work, false), fallback )
}
- static class ListCommand extends AbstractHystrixCommand<List> {
- ListCommand(String groupKey, String commandKey, Closure work, Closure fallback) {
+ static class ListCommand<T> extends AbstractHystrixCommand<List<T>> {
+ ListCommand(String groupKey, String commandKey, Callable<List<T>> work, Callable<List<T>> fallback) {
super(groupKey, commandKey, work, fallback)
}
}
- static class MapCommand extends AbstractHystrixCommand<Map> {
- MapCommand(String groupKey, String commandKey, Closure work, Closure fallback) {
+ static class MapCommand<K, V> extends AbstractHystrixCommand<Map<K, V>> {
+ MapCommand(String groupKey, String commandKey, Callable<Map<K, V>> work, Callable<Map<K, V>> fallback) {
super(groupKey, commandKey, work, fallback)
}
}
static class StringCommand extends AbstractHystrixCommand<String> {
- StringCommand(String groupKey, String commandKey, Closure work, Closure fallback) {
+ StringCommand(String groupKey, String commandKey, Callable<String> work, Callable<String> fallback) {
super(groupKey, commandKey, work, fallback)
}
}
static class VoidCommand extends AbstractHystrixCommand<Void> {
- VoidCommand(String groupKey, String commandKey, Closure work, Closure fallback) {
+ VoidCommand(String groupKey, String commandKey, Callable<Void> work, Callable<Void> fallback) {
super(groupKey, commandKey, work, fallback)
}
}

MODIFY
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/NetworkService.groovy
package com.netflix.spinnaker.gate.services
+import java.util.concurrent.Callable
import com.netflix.hystrix.HystrixCommand
import com.netflix.spinnaker.gate.services.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.ClouddriverService
@@ -32,12 +33,12 @@ class NetworkService {
@Autowired
ClouddriverService clouddriverService
- private static <T extends List> HystrixCommand<T> listCommand(String type, Closure<T> work) {
- (HystrixCommand<T>)HystrixFactory.newListCommand(GROUP, type, work)
+ private static HystrixCommand<List> listCommand(String type, Callable<List> work) {
+ HystrixFactory.newListCommand(GROUP, type, work)
}
- private static <T extends Map> HystrixCommand<T> mapCommand(String type, Closure<T> work) {
- (HystrixCommand<T>)HystrixFactory.newMapCommand(GROUP, type, work)
+ private static HystrixCommand<Map> mapCommand(String type, Callable<Map> work) {
+ HystrixFactory.newMapCommand(GROUP, type, work)
}
Map getNetworks() {

MODIFY
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy
gate-web/src/main/groovy/com/netflix/spinnaker/gate/services/aws/InfrastructureService.groovy
package com.netflix.spinnaker.gate.services.aws
+import java.util.concurrent.Callable
import com.netflix.hystrix.HystrixCommand
import com.netflix.spinnaker.gate.services.commands.HystrixFactory
import com.netflix.spinnaker.gate.services.internal.ClouddriverService
@@ -32,8 +33,8 @@ class InfrastructureService {
@Autowired
ClouddriverService clouddriverService
- private static <T extends List> HystrixCommand<T> command(String type, Closure<T> work) {
- (HystrixCommand<T>)HystrixFactory.newListCommand(GROUP, type, work)
+ private static HystrixCommand<List> command(String type, Callable<List> work) {
+ (HystrixCommand<List>)HystrixFactory.newListCommand(GROUP, type, work)
}
List<Map> getInstanceTypes() {

chore(kork): fix compatibility with latest kork