Class PBEventRecovery
The PB on-disk format uses newline (LF, 0x0a) as the record separator.
LineByteStream.readLine() splits on bare 0x0a bytes; write-time escaping via
LineEscaper.escapeNewLines() is the guarantee that no 0x0a appears unescaped within
a record body under normal conditions. If a record nonetheless contains a bare 0x0a — due to
hardware corruption, data from an external source, or any other cause — readLine()
truncates the record at that byte, leaving an orphaned varint field tag in the
ByteArray. A plain mergeFrom() then fails with
InvalidProtocolBufferException.
Recovery: if the initial parse fails and the last unescaped byte is an orphaned varint
field tag (wire type 0, non-zero), append 0x0a (the byte consumed by readLine()) and
retry with buildPartial(). This reconstructs the truncated field value and avoids a
silent event drop.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <M> MparseWithRecovery(Supplier<com.google.protobuf.AbstractMessageLite.Builder> builderFactory, ByteArray bar) Unescapesbarand parses it with the supplied builder factory.
-
Method Details
-
parseWithRecovery
public static <M> M parseWithRecovery(Supplier<com.google.protobuf.AbstractMessageLite.Builder> builderFactory, ByteArray bar) Unescapesbarand parses it with the supplied builder factory. If the first parse fails and the last byte looks like an orphaned varint field tag (wire type 0, non-zero), appends 0x0a (the LF byte thatreadLine()consumed as a record separator) and retries once withbuildPartial(). ThrowsPBParseExceptionif neither attempt succeeds.Usage in each PB event class:
dbevent = PBEventRecovery.parseWithRecovery(EPICSEvent.ScalarEnum::newBuilder, bar);
-