Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -175,14 +175,18 @@ private Collection<DataBuffer> processDataBuffer(DataBuffer buffer, DataBufferUt
public final T decode(DataBuffer dataBuffer, ResolvableType elementType,
@Nullable MimeType mimeType, @Nullable Map<String, Object> hints) {

Charset charset = getCharset(mimeType);
T value = decodeInternal(dataBuffer, charset);
DataBufferUtils.release(dataBuffer);
LogFormatUtils.traceDebug(logger, traceOn -> {
String formatted = LogFormatUtils.formatValue(value, !traceOn);
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
});
return value;
try {
Charset charset = getCharset(mimeType);
T value = decodeInternal(dataBuffer, charset);
LogFormatUtils.traceDebug(logger, traceOn -> {
String formatted = LogFormatUtils.formatValue(value, !traceOn);
return Hints.getLogPrefix(hints) + "Decoded " + formatted;
});
return value;
}
finally {
DataBufferUtils.release(dataBuffer);
}
}

private Charset getCharset(@Nullable MimeType mimeType) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ public DataBufferLimitException(String message) {
super(message);
}

public DataBufferLimitException(String message, Throwable cause) {
super(message, cause);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,12 @@ public int hashCode() {

@Override
public String toString() {
return this.byteBuf.toString();
try {
return this.byteBuf.toString();
}
catch (OutOfMemoryError ex) {
throw new DataBufferLimitException("Failed to convert data buffer to string: " + ex.getMessage(), ex);
}
}


Expand Down