Skip to content

Commit 6fe8cb9

Browse files
committed
Workaround for Synchronoss content-length limitation
Issue: SPR-17345
1 parent 8422976 commit 6fe8cb9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-web/src/main/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReader.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void accept(FluxSink<Part> emitter) {
127127
MediaType mediaType = headers.getContentType();
128128
Assert.state(mediaType != null, "No content type set");
129129

130-
int length = Math.toIntExact(headers.getContentLength());
130+
int length = getContentLength(headers);
131131
Charset charset = Optional.ofNullable(mediaType.getCharset()).orElse(StandardCharsets.UTF_8);
132132
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name());
133133

@@ -165,7 +165,12 @@ public void accept(FluxSink<Part> emitter) {
165165
listener.onError("Exception thrown while closing the parser", ex);
166166
}
167167
});
168+
}
168169

170+
private int getContentLength(HttpHeaders headers) {
171+
// Until this is fixed https://github.com/synchronoss/nio-multipart/issues/10
172+
long length = headers.getContentLength();
173+
return (int) length == length ? (int) length : -1;
169174
}
170175
}
171176

0 commit comments

Comments
 (0)