Skip to content

Commit 96d1187

Browse files
committed
Do not fail on empty beans
1 parent aaefe87 commit 96d1187

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/main/java/com/github/dockerjava/jaxrs/JerseyDockerCmdExecFactory.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.github.dockerjava.jaxrs;
22

3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.SerializationFeature;
35
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
46
import com.github.dockerjava.api.command.AttachContainerCmd;
57
import com.github.dockerjava.api.command.AuthCmd;
@@ -140,7 +142,10 @@ public void init(DockerClientConfig dockerClientConfig) {
140142

141143
clientConfig.register(ResponseStatusExceptionFilter.class);
142144
clientConfig.register(JsonClientFilter.class);
143-
clientConfig.register(JacksonJsonProvider.class);
145+
146+
ObjectMapper objectMapper = new ObjectMapper();
147+
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
148+
clientConfig.register(new JacksonJsonProvider(objectMapper));
144149

145150
// logging may disabled via log level
146151
clientConfig.register(new SelectiveLoggingFilter(LOGGER, true));

src/main/java/com/github/dockerjava/netty/handler/JsonRequestHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.dockerjava.netty.handler;
22

3+
import com.fasterxml.jackson.databind.SerializationFeature;
34
import io.netty.buffer.ByteBuf;
45
import io.netty.channel.ChannelHandlerContext;
56
import io.netty.handler.codec.MessageToByteEncoder;
@@ -15,6 +16,10 @@ public class JsonRequestHandler extends MessageToByteEncoder<Object> {
1516

1617
private ObjectMapper mapper = new ObjectMapper();
1718

19+
public JsonRequestHandler() {
20+
mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
21+
}
22+
1823
@Override
1924
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
2025
byte[] serialized = mapper.writeValueAsBytes(msg);

src/main/java/com/github/dockerjava/netty/handler/JsonResponseCallbackHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.dockerjava.netty.handler;
22

3+
import com.fasterxml.jackson.databind.SerializationFeature;
34
import io.netty.buffer.ByteBuf;
45
import io.netty.channel.ChannelHandlerContext;
56
import io.netty.channel.SimpleChannelInboundHandler;
@@ -24,6 +25,7 @@ public class JsonResponseCallbackHandler<T> extends SimpleChannelInboundHandler<
2425
public JsonResponseCallbackHandler(TypeReference<T> typeReference, ResultCallback<T> callback) {
2526
this.typeReference = typeReference;
2627
this.callback = callback;
28+
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
2729
}
2830

2931
@Override

0 commit comments

Comments
 (0)