Invoke onNext closure's call() method explicitly
Fix
MODIFY
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImagesFunctionalTest.groovy
src/functTest/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImagesFunctionalTest.groovy
@@ -36,4 +36,23 @@ task listImages(type: DockerListImages) {
then:
noExceptionThrown()
}
+
+ def "can list images and handle empty result"() {
+ buildFile << """
+import com.bmuschko.gradle.docker.tasks.image.DockerListImages
+
+task listImages(type: DockerListImages) {
+ showAll = true
+ filters = "project=none-image-match"
+ onNext {
+ }
+}
+"""
+
+ when:
+ build('listImages')
+
+ then:
+ noExceptionThrown()
+ }
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCopyFileFromContainer.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCopyFileFromContainer.groovy
@@ -60,7 +60,7 @@ class DockerCopyFileFromContainer extends DockerExistingContainer {
tarStream = containerCommand.exec()
if(onNext) {
- onNext(tarStream)
+ onNext.call(tarStream)
} else {
def hostDestination = new File(hostPath)

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCreateContainer.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerCreateContainer.groovy
@@ -163,7 +163,7 @@ class DockerCreateContainer extends AbstractDockerRemoteApiTask {
logger.quiet "Created container with ID '$container.id'."
containerId = container.id
if(onNext) {
- onNext(container)
+ onNext.call(container)
}
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerInspectContainer.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/container/DockerInspectContainer.groovy
@@ -27,7 +27,7 @@ class DockerInspectContainer extends DockerExistingContainer {
def container = dockerClient.inspectContainerCmd(getContainerId()).exec()
if (onNext) {
- onNext(container)
+ onNext.call(container)
} else if (responseHandler) {
responseHandler.handle(container)
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerCommitImage.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerCommitImage.groovy
@@ -104,7 +104,7 @@ class DockerCommitImage extends DockerExistingContainer {
imageId = commitCmd.exec()
logger.quiet "Created image with ID '$imageId'."
if(onNext) {
- onNext(imageId)
+ onNext.call(imageId)
}
}
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerInspectImage.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerInspectImage.groovy
@@ -26,7 +26,7 @@ class DockerInspectImage extends DockerExistingImage {
logger.quiet "Inspecting image for with ID '${getImageId()}'."
def image = dockerClient.inspectImageCmd(getImageId()).exec()
if(onNext) {
- onNext(image)
+ onNext.call(image)
} else {
responseHandler.handle(image)
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImages.groovy
src/main/groovy/com/bmuschko/gradle/docker/tasks/image/DockerListImages.groovy
@@ -45,9 +45,8 @@ class DockerListImages extends AbstractDockerRemoteApiTask {
}
def images = listImagesCmd.exec()
-
if (onNext) {
- onNext(images)
+ onNext.call(images)
} else if (responseHandler) {
responseHandler.handle(images)
}

MODIFY
src/main/groovy/com/bmuschko/gradle/docker/utils/DockerThreadContextClassLoader.groovy
src/main/groovy/com/bmuschko/gradle/docker/utils/DockerThreadContextClassLoader.groovy
@@ -513,7 +513,7 @@ class DockerThreadContextClassLoader implements ThreadContextClassLoader {
enhancer.setCallback([
invoke: { Object proxy, Method method, Object[] args ->
if ("onNext" == method.name) {
- onNext(args[0])
+ onNext.call(args[0])
}
try {
method.invoke(defaultHandler, args)
@@ -547,7 +547,7 @@ class DockerThreadContextClassLoader implements ThreadContextClassLoader {
enhancer.setCallback([
invoke: { Object proxy, Method method, Object[] args ->
if ("onNext" == method.name) {
- onNext(args[0])
+ onNext.call(args[0])
}
try {
method.invoke(defaultHandler, args)

Invoke onNext closure's call() method explicitly (#368)

Fix #367