Skip to content

Commit 8a6441c

Browse files
committed
Fixed issue with StartContainerCmd
The accept header was being set incorrectly to text instead of json. Also added a defensive null check in JsonClientFilter.
1 parent d7d2515 commit 8a6441c

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/com/github/dockerjava/client/command/StartContainerCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected Void impl() throws DockerException {
8888

8989
try {
9090
LOGGER.trace("POST: {}", webResource);
91-
Builder builder = webResource.accept(MediaType.TEXT_PLAIN);
91+
Builder builder = webResource.accept(MediaType.APPLICATION_JSON);
9292
if (startContainerConfig != null) {
9393
builder.type(MediaType.APPLICATION_JSON).post(startContainerConfig);
9494
} else {

src/main/java/com/github/dockerjava/client/utils/JsonClientFilter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public ClientResponse handle(ClientRequest cr) {
1616
// Call the next filter
1717
ClientResponse resp = getNext().handle(cr);
1818
String respContentType = resp.getHeaders().getFirst("Content-Type");
19-
if (respContentType.startsWith("text/plain")) {
19+
if (respContentType != null && respContentType.startsWith("text/plain")) {
2020
String newContentType = "application/json" + respContentType.substring(10);
2121
resp.getHeaders().putSingle("Content-Type", newContentType);
2222
}

0 commit comments

Comments
 (0)