Disable useShortRepeatedPrimitives for Printer.DEFAULT_DEBUG_FORMAT

In addition, this change refactors DebugFormat so that it now uses Printer.DEFAULT_DEBUG_FORMAT.

PiperOrigin-RevId: 707623592
pull/19708/head
Protobuf Team Bot 2 months ago committed by Copybara-Service
parent 880d2b0574
commit 1900cbe0da
  1. 23
      java/core/src/main/java/com/google/protobuf/DebugFormat.java
  2. 2
      java/core/src/main/java/com/google/protobuf/TextFormat.java

@ -23,25 +23,30 @@ public final class DebugFormat {
}
public String toString(MessageOrBuilder message) {
return TextFormat.printer()
if (!this.isSingleLine) {
return TextFormat.debugFormatPrinter()
.printToString(message, TextFormat.Printer.FieldReporterLevel.DEBUG_MULTILINE);
}
return TextFormat.debugFormatPrinter()
.emittingSingleLine(this.isSingleLine)
.enablingSafeDebugFormat(true)
.printToString(message, this.isSingleLine
? TextFormat.Printer.FieldReporterLevel.DEBUG_SINGLE_LINE
: TextFormat.Printer.FieldReporterLevel.DEBUG_MULTILINE);
.printToString(message, TextFormat.Printer.FieldReporterLevel.DEBUG_SINGLE_LINE);
}
public String toString(FieldDescriptor field, Object value) {
return TextFormat.printer()
if (!this.isSingleLine) {
return TextFormat.debugFormatPrinter().printFieldToString(field, value);
}
return TextFormat.debugFormatPrinter()
.emittingSingleLine(this.isSingleLine)
.enablingSafeDebugFormat(true)
.printFieldToString(field, value);
}
public String toString(UnknownFieldSet fields) {
return TextFormat.printer()
if (!this.isSingleLine) {
return TextFormat.debugFormatPrinter().printToString(fields);
}
return TextFormat.debugFormatPrinter()
.emittingSingleLine(this.isSingleLine)
.enablingSafeDebugFormat(true)
.printToString(fields);
}

@ -135,7 +135,7 @@ public final class TextFormat {
private static final Printer DEFAULT_DEBUG_FORMAT =
new Printer(
/* escapeNonAscii= */ true,
/* useShortRepeatedPrimitives= */ true,
/* useShortRepeatedPrimitives= */ false,
TypeRegistry.getEmptyTypeRegistry(),
ExtensionRegistryLite.getEmptyRegistry(),
/* enablingSafeDebugFormat= */ true,

Loading…
Cancel
Save