Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ccabc1a4
Commit
ccabc1a4
authored
Aug 28, 2020
by
Scott Frederick
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x'
Closes gh-23133
parents
06a1fdd8
4f1b4c98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
1 deletion
+37
-1
DockerApi.java
...ngframework/boot/buildpack/platform/docker/DockerApi.java
+26
-1
DockerApiTests.java
...mework/boot/buildpack/platform/docker/DockerApiTests.java
+11
-0
No files found.
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/docker/DockerApi.java
View file @
ccabc1a4
...
...
@@ -175,11 +175,18 @@ public class DockerApi {
Assert
.
notNull
(
archive
,
"Archive must not be null"
);
Assert
.
notNull
(
listener
,
"Listener must not be null"
);
URI
loadUri
=
buildUrl
(
"/images/load"
);
StreamCaptureUpdateListener
streamListener
=
new
StreamCaptureUpdateListener
();
listener
.
onStart
();
try
{
try
(
Response
response
=
http
().
post
(
loadUri
,
"application/x-tar"
,
archive:
:
writeTo
))
{
jsonStream
().
get
(
response
.
getContent
(),
LoadImageUpdateEvent
.
class
,
listener:
:
onUpdate
);
jsonStream
().
get
(
response
.
getContent
(),
LoadImageUpdateEvent
.
class
,
(
event
)
->
{
streamListener
.
onUpdate
(
event
);
listener
.
onUpdate
(
event
);
});
}
Assert
.
state
(
StringUtils
.
hasText
(
streamListener
.
getCapturedStream
()),
"Invalid response received when loading image "
+
((
archive
.
getTag
()
!=
null
)
?
"\""
+
archive
.
getTag
()
+
"\""
:
""
));
}
finally
{
listener
.
onFinish
();
...
...
@@ -363,4 +370,22 @@ public class DockerApi {
}
/**
* {@link UpdateListener} used to ensure an image load response stream.
*/
private
static
class
StreamCaptureUpdateListener
implements
UpdateListener
<
LoadImageUpdateEvent
>
{
private
String
stream
;
@Override
public
void
onUpdate
(
LoadImageUpdateEvent
event
)
{
this
.
stream
=
event
.
getStream
();
}
String
getCapturedStream
()
{
return
this
.
stream
;
}
}
}
spring-boot-project/spring-boot-tools/spring-boot-buildpack-platform/src/test/java/org/springframework/boot/buildpack/platform/docker/DockerApiTests.java
View file @
ccabc1a4
...
...
@@ -51,6 +51,7 @@ import org.springframework.boot.buildpack.platform.io.TarArchive;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalArgumentException
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThatIllegalStateException
;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
...
...
@@ -172,6 +173,16 @@ class DockerApiTests {
.
withMessage
(
"Listener must not be null"
);
}
@Test
// gh-23130
void
loadWithEmptyResponseThrowsException
()
throws
Exception
{
Image
image
=
Image
.
of
(
getClass
().
getResourceAsStream
(
"type/image.json"
));
ImageArchive
archive
=
ImageArchive
.
from
(
image
);
URI
loadUri
=
new
URI
(
IMAGES_URL
+
"/load"
);
given
(
http
().
post
(
eq
(
loadUri
),
eq
(
"application/x-tar"
),
any
())).
willReturn
(
emptyResponse
());
assertThatIllegalStateException
().
isThrownBy
(()
->
this
.
api
.
load
(
archive
,
this
.
loadListener
))
.
withMessageContaining
(
"Invalid response received"
);
}
@Test
void
loadLoadsImage
()
throws
Exception
{
Image
image
=
Image
.
of
(
getClass
().
getResourceAsStream
(
"type/image.json"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment