Collections.EMPTY_MAP is immutable but used as Default-Parameter and will produce an UnsupportedOperationException, because internal putMethod will use it to add the Content-Type-Header later on.
if (contentType == null) {
if (((Map)headerMap).get("Content-Type") == null) {
((Map)headerMap).put("Content-Type", "application/octet-stream");
}
} else {
((Map)headerMap).put("Content-Type", contentType);
}
Replace it with null, thus the internal putObject will initialize it with a mutable HashMap.
Collections.EMPTY_MAP is immutable but used as Default-Parameter and will produce an UnsupportedOperationException, because internal putMethod will use it to add the Content-Type-Header later on.
Replace it with null, thus the internal putObject will initialize it with a mutable HashMap.