[jOOQ/jOOQ#13290] NullPointerException in Result.formatJSON() when a Record is null

This commit is contained in:
Lukas Eder 2022-03-16 15:08:16 +01:00
parent c0fb8c95c4
commit e64584ca65

View File

@ -606,7 +606,7 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
}
}
private static final void formatJSON0(Object value, Writer writer, JSONFormat format) throws java.io.IOException {
static final void formatJSON0(Object value, Writer writer, JSONFormat format) throws java.io.IOException {
// [#2741] TODO: This logic will be externalised in new SPI
if (value instanceof byte[]) { byte[] a = (byte[]) value;
@ -651,6 +651,11 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
int recordLevel,
Writer writer
) throws java.io.IOException {
if (record == null) {
writer.append("null");
return;
}
String separator = "";
int size = fields.size();
boolean wrapRecords = format.wrapSingleColumnRecords() || size > 1;
@ -699,6 +704,11 @@ abstract class AbstractResult<R extends Record> extends AbstractFormattable impl
int recordLevel,
Writer writer
) throws java.io.IOException {
if (record == null) {
writer.append("null");
return;
}
String separator = "";
int size = fields.size();
boolean wrapRecords = format.wrapSingleColumnRecords() || size > 1;