28
28
import com .palantir .logsafe .SafeArg ;
29
29
import com .palantir .logsafe .exceptions .SafeIllegalArgumentException ;
30
30
import com .palantir .logsafe .exceptions .SafeIoException ;
31
- import java .io .FilterOutputStream ;
32
31
import java .io .IOException ;
33
- import java .io .OutputStream ;
34
32
35
33
// TODO(rfink): Consider async Jackson, see
36
34
// https://github.com/spring-projects/spring-framework/commit/31e0e537500c0763a36d3af2570d5c253a374690
@@ -69,7 +67,7 @@ public final boolean supportsContentType(String contentType) {
69
67
}
70
68
71
69
@ Override
72
- public <T > Serializer <T > serializer (TypeMarker <T > type ) {
70
+ public final <T > Serializer <T > serializer (TypeMarker <T > type ) {
73
71
ObjectWriter writer = mapper .writerFor (mapper .constructType (type .getType ()));
74
72
return (value , output ) -> {
75
73
Preconditions .checkNotNull (value , "cannot serialize null value" );
@@ -78,7 +76,7 @@ public <T> Serializer<T> serializer(TypeMarker<T> type) {
78
76
}
79
77
80
78
@ Override
81
- public <T > Deserializer <T > deserializer (TypeMarker <T > type ) {
79
+ public final <T > Deserializer <T > deserializer (TypeMarker <T > type ) {
82
80
ObjectReader reader = mapper .readerFor (mapper .constructType (type .getType ()));
83
81
return input -> {
84
82
try {
@@ -134,12 +132,6 @@ public static Encoding cbor() {
134
132
public String getContentType () {
135
133
return CONTENT_TYPE ;
136
134
}
137
-
138
- @ Override
139
- public <T > Serializer <T > serializer (TypeMarker <T > type ) {
140
- Serializer <T > delegate = super .serializer (type );
141
- return (value , output ) -> delegate .serialize (value , new ShieldingOutputStream (output ));
142
- }
143
135
};
144
136
}
145
137
@@ -149,24 +141,4 @@ private static ObjectMapper configure(ObjectMapper mapper) {
149
141
// Avoid flushing, allowing us to set content-length if the length is below the buffer size.
150
142
.disable (JsonGenerator .Feature .FLUSH_PASSED_TO_STREAM );
151
143
}
152
-
153
- /**
154
- * Work around a CBORGenerator bug. For more information:
155
- * https://github.com/FasterXML/jackson-dataformats-binary/issues/155
156
- */
157
- private static final class ShieldingOutputStream extends FilterOutputStream {
158
- ShieldingOutputStream (OutputStream out ) {
159
- super (out );
160
- }
161
-
162
- @ Override
163
- public void flush () {
164
- // nop
165
- }
166
-
167
- @ Override
168
- public void close () {
169
- // nop
170
- }
171
- }
172
144
}
0 commit comments