Protobuf parse error required fields missing cannot determine missing fields for lite message

diadoc,diadocsdk-1c-docs | Protobuf parse error: required fields missing: (cannot determine missing fields for lite message)

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

message_lite.h

message_lite.h

#include <google/protobuf/message_lite.h>
namespace google::protobuf

Defines MessageLite, the abstract interface implemented by all (lite and non-lite) protocol message objects.

Classes in this file

MessageLite

Interface to light weight protocol messages.

File Members

These definitions are not part of any class.

void

ShutdownProtobufLibrary()

Shut down the entire protocol buffers library, deleting all static-duration objects allocated by the library or by generated .pb.cc files. more…


void protobuf::ShutdownProtobufLibrary()

Shut down the entire protocol buffers library, deleting all static-duration objects allocated by the library or by generated .pb.cc files.

There are two reasons you might want to call this:

  • You use a draconian definition of «memory leak» in which you expect every single malloc() to have a corresponding free(), even for objects which live until program exit.
  • You are writing a dynamically-loaded library which needs to clean up after itself when the library is unloaded.

It is safe to call this multiple times. However, it is not safe to use any other part of the protocol buffers library after ShutdownProtobufLibrary() has been called. Furthermore this call is not thread safe, user needs to synchronize multiple calls.

class MessageLite

#include <google/protobuf/message_lite.h>
namespace google::protobuf

Interface to light weight protocol messages.

This interface is implemented by all protocol message objects. Non-lite messages additionally implement the Message interface, which is a subclass of MessageLite. Use MessageLite instead when you only need the subset of features which it supports – namely, nothing that uses descriptors or reflection. You can instruct the protocol compiler to generate classes which implement only MessageLite, not the full Message interface, by adding the following line to the .proto file:

option optimize_for = LITE_RUNTIME;

This is particularly useful on resource-constrained systems where the full protocol buffers runtime library is too big.

Note that on non-constrained systems (e.g. servers) when you need to link in lots of protocol definitions, a better way to reduce total code footprint is to use optimize_for = CODE_SIZE. This will make the generated code smaller while still supporting all the same features (at the expense of speed). optimize_for = LITE_RUNTIME is best when you only have a small number of message types linked into your binary, in which case the size of the protocol buffers runtime itself is the biggest problem.

Users must not derive from this class. Only the protocol compiler and the internal library are allowed to create subclasses.

Known subclasses:

  • Message

Members

enum

ParseFlags

more…

protected internal::InternalMetadata

_internal_metadata_

constexpr

MessageLite()

virtual

~MessageLite()

template bool

ParseFrom(const T & input)

virtual uint8 *

_InternalSerialize(uint8 * ptr, io::EpsCopyOutputStream * stream) const = 0

Fast path when conditions match (ie. more…

bool

IsInitializedWithErrors() const

Identical to IsInitialized() except that it logs an error message.

protected template static T *

CreateMaybeMessage(Arena * arena)

protected explicit

MessageLite(Arena * arena)

protected Arena *

GetOwningArena() const

Returns the arena, if any, that directly owns this message and its internal memory (Arena::Own is different in that the arena doesn’t directly own the internal memory). more…

protected Arena *

GetArenaForAllocation() const

Returns the arena, used for allocating internal objects(e.g., child messages, etc), or owning incoming objects (e.g., set allocated).

Basic Operations

virtual std::string

GetTypeName() const = 0

Get the name of this message type, e.g. «foo.bar.BazProto».

virtual MessageLite *

New() const = 0

Construct a new instance of the same type. more…

virtual MessageLite *

New(Arena * arena) const

Construct a new instance on the arena. more…

Arena *

GetArena() const

Same as GetOwningArena.

void *

GetMaybeArenaPointer() const

Get a pointer that may be equal to this message’s arena, or may not be. more…

virtual void

Clear() = 0

Clear all fields of the message and set them to their default values. more…

virtual bool

IsInitialized() const = 0

Quickly check if all required fields have values set.

virtual std::string

InitializationErrorString() const

This is not implemented for Lite messages – it just returns «(cannot
determine missing fields for lite message)». more…

virtual void

CheckTypeAndMergeFrom(const MessageLite & other) = 0

If |other| is the exact same class as this, calls MergeFrom(). more…

std::string

DebugString() const

These methods return a human-readable summary of the message. more…

std::string

ShortDebugString() const

std::string

Utf8DebugString() const

MessageLite::DebugString is already Utf8 Safe. more…

Parsing

Methods for parsing in protocol buffer format.

Most of these are just simple wrappers around MergeFromCodedStream(). Clear() will be called before merging the input.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromCodedStream(io::CodedInputStream * input)

Fill the message with a protocol buffer parsed from the given input stream. more…

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromCodedStream(io::CodedInputStream * input)

Like ParseFromCodedStream(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromZeroCopyStream(io::ZeroCopyInputStream * input)

Read a protocol buffer from the given zero-copy input stream. more…

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromZeroCopyStream(io::ZeroCopyInputStream * input)

Like ParseFromZeroCopyStream(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromFileDescriptor(int file_descriptor)

Parse a protocol buffer from a file descriptor. more…

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromFileDescriptor(int file_descriptor)

Like ParseFromFileDescriptor(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromIstream(std::istream * input)

Parse a protocol buffer from a C++ istream. more…

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromIstream(std::istream * input)

Like ParseFromIstream(), but accepts messages that are missing required fields.

bool

MergePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)

Read a protocol buffer from the given zero-copy input stream, expecting the message to be exactly «size» bytes long. more…

bool

MergeFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)

Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromBoundedZeroCopyStream(io::ZeroCopyInputStream * input, int size)

Like ParseFromBoundedZeroCopyStream(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromString(ConstStringParam data)

Parses a protocol buffer contained in a string. more…

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromString(ConstStringParam data)

Like ParseFromString(), but accepts messages that are missing required fields.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParseFromArray(const void * data, int size)

Parse a protocol buffer contained in an array of bytes.

PROTOBUF_ATTRIBUTE_REINITIALIZES bool

ParsePartialFromArray(const void * data, int size)

Like ParseFromArray(), but accepts messages that are missing required fields.

bool

MergeFromCodedStream(io::CodedInputStream * input)

Reads a protocol buffer from the stream and merges it into this Message. more…

bool

MergePartialFromCodedStream(io::CodedInputStream * input)

Like MergeFromCodedStream(), but succeeds even if required fields are missing in the input. more…

bool

MergeFromString(ConstStringParam data)

Merge a protocol buffer contained in a string.

Serialization

Methods for serializing in protocol buffer format.

Most of these are just simple wrappers around ByteSize() and SerializeWithCachedSizes().

bool

SerializeToCodedStream(io::CodedOutputStream * output) const

Write a protocol buffer of this message to the given output. more…

bool

SerializePartialToCodedStream(io::CodedOutputStream * output) const

Like SerializeToCodedStream(), but allows missing required fields.

bool

SerializeToZeroCopyStream(io::ZeroCopyOutputStream * output) const

Write the message to the given zero-copy output stream. more…

bool

SerializePartialToZeroCopyStream(io::ZeroCopyOutputStream * output) const

Like SerializeToZeroCopyStream(), but allows missing required fields.

bool

SerializeToString(std::string * output) const

Serialize the message and store it in the given string. more…

bool

SerializePartialToString(std::string * output) const

Like SerializeToString(), but allows missing required fields.

bool

SerializeToArray(void * data, int size) const

Serialize the message and store it in the given byte array. more…

bool

SerializePartialToArray(void * data, int size) const

Like SerializeToArray(), but allows missing required fields.

std::string

SerializeAsString() const

Make a string encoding the message. more…

std::string

SerializePartialAsString() const

Like SerializeAsString(), but allows missing required fields.

bool

SerializeToFileDescriptor(int file_descriptor) const

Serialize the message and write it to the given file descriptor. more…

bool

SerializePartialToFileDescriptor(int file_descriptor) const

Like SerializeToFileDescriptor(), but allows missing required fields.

bool

SerializeToOstream(std::ostream * output) const

Serialize the message and write it to the given C++ ostream. more…

bool

SerializePartialToOstream(std::ostream * output) const

Like SerializeToOstream(), but allows missing required fields.

bool

AppendToString(std::string * output) const

Like SerializeToString(), but appends to the data to the string’s existing contents. more…

bool

AppendPartialToString(std::string * output) const

Like AppendToString(), but allows missing required fields.

virtual size_t

ByteSizeLong() const = 0

Computes the serialized size of the message. more…

int

ByteSize() const

Legacy ByteSize() API.

void

SerializeWithCachedSizes(io::CodedOutputStream * output) const

Serializes the message without recomputing the size. more…

uint8 *

SerializeWithCachedSizesToArray(uint8 * target) const

Like SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written. more…

virtual int

GetCachedSize() const = 0

Returns the result of the last call to ByteSize(). more…

virtual const char *

_InternalParse(const char * , internal::ParseContext * )


enum MessageLite::ParseFlags {
  kMerge = = 0,
  kParse = = 1,
  kMergePartial = = 2,
  kParsePartial = = 3,
  kMergeWithAliasing = = 4,
  kParseWithAliasing = = 5,
  kMergePartialWithAliasing = = 6,
  kParsePartialWithAliasing = = 7
}

kMerge
kParse
kMergePartial
kParsePartial
kMergeWithAliasing
kParseWithAliasing
kMergePartialWithAliasing
kParsePartialWithAliasing

virtual uint8 * MessageLite::_InternalSerialize(
        uint8 * ptr,
        io::EpsCopyOutputStream * stream) const = 0

Fast path when conditions match (ie.

non-deterministic) uint8* _InternalSerialize(uint8* ptr) const;


protected Arena * MessageLite::GetOwningArena() const

Returns the arena, if any, that directly owns this message and its internal memory (Arena::Own is different in that the arena doesn’t directly own the internal memory).

This method is used in proto’s implementation for swapping, moving and setting allocated, for deciding whether the ownership of this message or its internal memory could be changed.


virtual MessageLite * MessageLite::New() const = 0

Construct a new instance of the same type.

Ownership is passed to the caller.


virtual MessageLite * MessageLite::New(
        Arena * arena) const

Construct a new instance on the arena.

Ownership is passed to the caller if arena is a NULL. Default implementation for backwards compatibility.


void * MessageLite::GetMaybeArenaPointer() const

Get a pointer that may be equal to this message’s arena, or may not be.

If the value returned by this method is equal to some arena pointer, then this message is on that arena; however, if this message is on some arena, this method may or may not return that arena’s pointer. As a tradeoff, this method may be more efficient than GetArena(). The intent is to allow underlying representations that use e.g. tagged pointers to sometimes store the arena pointer directly, and sometimes in a more indirect way, and allow a fastpath comparison against the arena pointer when it’s easy to obtain.


virtual void MessageLite::Clear() = 0

Clear all fields of the message and set them to their default values.

Clear() avoids freeing memory, assuming that any memory allocated to hold parts of the message will be needed again to hold the next message. If you actually want to free the memory used by a Message, you must delete it.


virtual std::string MessageLite::InitializationErrorString() const

This is not implemented for Lite messages – it just returns «(cannot
determine missing fields for lite message)».

However, it is implemented for full messages. See message.h.


virtual void MessageLite::CheckTypeAndMergeFrom(
        const MessageLite & other) = 0

If |other| is the exact same class as this, calls MergeFrom().

Otherwise, results are undefined (probably crash).


std::string MessageLite::DebugString() const

These methods return a human-readable summary of the message.

Note that since the MessageLite interface does not support reflection, there is very little information that these methods can provide. They are shadowed by methods of the same name on the Message interface which provide much more information. The methods here are intended primarily to facilitate code reuse for logic that needs to interoperate with both full and lite protos.

The format of the returned string is subject to change, so please do not assume it will remain stable over time.


std::string MessageLite::Utf8DebugString() const


PROTOBUF_ATTRIBUTE_REINITIALIZES bool
    MessageLite::ParseFromCodedStream(
        io::CodedInputStream * input)

Fill the message with a protocol buffer parsed from the given input stream.

Returns false on a read error or if the input is in the wrong format. A successful return does not indicate the entire input is consumed, ensure you call ConsumedEntireMessage() to check that if applicable.


PROTOBUF_ATTRIBUTE_REINITIALIZES bool
    MessageLite::ParseFromZeroCopyStream(
        io::ZeroCopyInputStream * input)

Read a protocol buffer from the given zero-copy input stream.

If successful, the entire input will be consumed.


PROTOBUF_ATTRIBUTE_REINITIALIZES bool
    MessageLite::ParseFromFileDescriptor(
        int file_descriptor)

Parse a protocol buffer from a file descriptor.

If successful, the entire input will be consumed.


PROTOBUF_ATTRIBUTE_REINITIALIZES bool
    MessageLite::ParseFromIstream(
        std::istream * input)

Parse a protocol buffer from a C++ istream.

If successful, the entire input will be consumed.


bool MessageLite::MergePartialFromBoundedZeroCopyStream(
        io::ZeroCopyInputStream * input,
        int size)

Read a protocol buffer from the given zero-copy input stream, expecting the message to be exactly «size» bytes long.

If successful, exactly this many bytes will have been consumed from the input.


PROTOBUF_ATTRIBUTE_REINITIALIZES bool
    MessageLite::ParseFromString(
        ConstStringParam data)


bool MessageLite::MergeFromCodedStream(
        io::CodedInputStream * input)

Reads a protocol buffer from the stream and merges it into this Message.

Singular fields read from the what is already in the Message and repeated fields are appended to those already present.

It is the responsibility of the caller to call input->LastTagWas() (for groups) or input->ConsumedEntireMessage() (for non-groups) after this returns to verify that the message’s end was delimited correctly.

ParseFromCodedStream() is implemented as Clear() followed by MergeFromCodedStream().


bool MessageLite::MergePartialFromCodedStream(
        io::CodedInputStream * input)


bool MessageLite::SerializeToCodedStream(
        io::CodedOutputStream * output) const

Write a protocol buffer of this message to the given output.

Returns false on a write error. If the message is missing required fields, this may GOOGLE_CHECK-fail.


bool MessageLite::SerializeToZeroCopyStream(
        io::ZeroCopyOutputStream * output) const

Write the message to the given zero-copy output stream.

All required fields must be set.


bool MessageLite::SerializeToString(
        std::string * output) const

Serialize the message and store it in the given string.

All required fields must be set.


bool MessageLite::SerializeToArray(
        void * data,
        int size) const

Serialize the message and store it in the given byte array.

All required fields must be set.


std::string MessageLite::SerializeAsString() const

Make a string encoding the message.

Is equivalent to calling SerializeToString() on a string and using that. Returns the empty string if SerializeToString() would have returned an error. Note: If you intend to generate many such strings, you may reduce heap fragmentation by instead re-using the same string object with calls to SerializeToString().


bool MessageLite::SerializeToFileDescriptor(
        int file_descriptor) const

Serialize the message and write it to the given file descriptor.

All required fields must be set.


bool MessageLite::SerializeToOstream(
        std::ostream * output) const

Serialize the message and write it to the given C++ ostream.

All required fields must be set.


bool MessageLite::AppendToString(
        std::string * output) const

Like SerializeToString(), but appends to the data to the string’s existing contents.

All required fields must be set.


virtual size_t MessageLite::ByteSizeLong() const = 0

Computes the serialized size of the message.

This recursively calls ByteSizeLong() on all embedded messages.

ByteSizeLong() is generally linear in the number of fields defined for the proto.


void MessageLite::SerializeWithCachedSizes(
        io::CodedOutputStream * output) const

Serializes the message without recomputing the size.

The message must not have changed since the last call to ByteSize(), and the value returned by ByteSize must be non-negative. Otherwise the results are undefined.


uint8 * MessageLite::SerializeWithCachedSizesToArray(
        uint8 * target) const

Like SerializeWithCachedSizes, but writes directly to *target, returning a pointer to the byte immediately after the last byte written.

«target» must point at a byte array of at least ByteSize() bytes. Whether to use deterministic serialization, e.g., maps in sorted order, is determined by CodedOutputStream::IsDefaultSerializationDeterministic().


virtual int MessageLite::GetCachedSize() const = 0

Returns the result of the last call to ByteSize().

An embedded message’s size is needed both to serialize it (because embedded messages are length-delimited) and to compute the outer message’s size. Caching the size avoids computing it multiple times.

ByteSize() does not automatically use the cached size when available because this would require invalidating it every time the message was modified, which would be too hard and expensive. (E.g. if a deeply-nested sub-message is changed, all of its parents’ cached sizes would need to be invalidated, which is too much work for an otherwise inlined setter method.)

Добрый день.

Общая информация для упрощения «разбора полётов»:
Организация: Тестовая организация №2918743
ИНН: 9629187430
КПП: 962901000
ID организации: 0d7430bf4a9d4acca06e3ba0720e3e91@diadoc.ru

Мы работаем с Диадок с использованием компонент АПИ для 1С
https://diadocsdk-1c.readthedocs.io/ru/latest/index.html
Текущая используемая версия: COM x64 5.35.4.736.

При попытке получения данных некоторых ранее уже успешно получаемых рабочих документов мы обнаружили, что более не можем получить все данные этих документов.

Все документы — исходящие УКД.

Список ID найденных документов:
971666a8-251b-49c2-b491-dc7534d2a1d159eca725-f90e-4de1-94be-24e0eb8b3b35
bc8b3a2e-9c81-464f-9b5d-0772810032e4fc2b595e-7c3e-472c-8a51-e25082d9f04a
28bec836-2c39-4a81-a3c3-133e3ce365ef4f5dcf7b-20fd-4a7a-9486-48c986c4c2a3
e77c4842-1e4e-4a24-b7cf-7a1fad150ea7ae3d06de-fc19-4dc9-830a-deb145348031
530bb425-94cb-4fbb-b751-1a404aa42e3eec4a688b-4a6b-4354-b560-e652dad10251
71e5bee7-c4a5-42d6-a3d1-c0a0b65097ae8e72653a-2b73-4671-b911-1789879205fd
acb31401-2dfc-4a4a-9196-35dc309b0f07ad2ff473-60bd-4136-aabd-acfaa1bcb3ea
e86199ee-8928-4f51-a361-0a8b5322e99f407c2736-97d4-4dcb-80a1-1012d8ef3c2d

Документы относительно свежие:
изображение

До какого-то момента документы нормально по АПИ получались. А именно — до момента их подписания получателями. Как только у этих документов появились данные подписи получателя (Buyer), то «что-то пошло не так» и 1С стало при обращении к GetDynamicContent(«Buyer») вылетать в исключение и возвращать ошибку вида:

Ошибка при вызове метода контекста (GetDynamicContent): Произошла исключительная ситуация (DocumentBase.GetDynamicContent): ##100[Ошибка сервера Диадок]code:400, HTTP error: Invalid content to parse for document type=[typeNamedId=UniversalCorrectionDocument, function=КСЧФДИС, version=ucd_05_01_03, titleIndex=1]

Т.е. по этим документам стабильно не выполняется GetDynamicContent(«Buyer»).
При этом GetDocumentByID() и GetDynamicContent(«Seller») выполняются без ошибок.

Странно то, что в 2021 у нас есть и другие исходящие УКД, КСЧФДИС, ucd_05_01_03 — И более ранние по сравнению с указанными, и более поздние. И с ними всё нормально! Никаких проблем при вызове GetDynamicContent(«Buyer») не возникает. Пример: 0afaeeaf-90e4-4b1d-965e-c9cc8cdadef939c9bdbd-76d3-4394-8a31-79158aaeff0a.

Ранее (5 марта 2021 года, обращение #595) мы уже писали вам о подобной проблеме. Но тогда она касалась документов в тестовых ящиках. А в данном случае проблема касается реальных рабочих документов. То обращение по-прежнему висит, помеченное, как «Bug». Как мы понимаем, проблема до сих пор не определена и не решена.

Большая просьба обратить внимание на проблему! И, если это возможно, исправить её.

Спасибо.

SyRenity

unread,

Apr 16, 2010, 10:05:57 PM4/16/10

to Protocol Buffers

Hi.

I’m getting occasionally the following error below in my Java app:

com.google.protobuf.InvalidProtocolBufferException: Message was

missing required fields. (Lite runtime could not determine which

fields were missing).

at

com.google.protobuf.UninitializedMessageException.asInvalidProtocolBufferException(UninitializedMessageException.java:

81)

at classes.cameraInfoProto$camera

$Builder.buildParsed(cameraInfoProto.java:242)

at classes.cameraInfoProto$camera$Builder.access

$11(cameraInfoProto.java:238)

at classes.cameraInfoProto

$camera.parseFrom(cameraInfoProto.java:133)

at app.jSockets.FetcherSockets

$ResponseThread.readMessage(FetcherSockets.java:386)

at app.jSockets.FetcherSockets

$ResponseThread.run(FetcherSockets.java:268)

I double-checked my code, but I have only a single required field, and

I’m always filling it up in the C++ app.

Any idea how to diagnose it?

Thanks.



You received this message because you are subscribed to the Google Groups «Protocol Buffers» group.

To post to this group, send email to prot…@googlegroups.com.

To unsubscribe from this group, send email to protobuf+u…@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

Henner Zeller

unread,

Apr 16, 2010, 10:11:19 PM4/16/10

to SyRenity, Protocol Buffers

On Fri, Apr 16, 2010 at 11:05, SyRenity <stas….@gmail.com> wrote:

> Hi.

>

> I’m getting occasionally the following error below in my Java app:

>

> com.google.protobuf.InvalidProtocolBufferException: Message was

> missing required fields.  (Lite runtime could not determine which

> fields were missing).

>        at

> com.google.protobuf.UninitializedMessageException.asInvalidProtocolBufferException(UninitializedMessageException.java:

> 81)

>        at classes.cameraInfoProto$camera

> $Builder.buildParsed(cameraInfoProto.java:242)

>        at classes.cameraInfoProto$camera$Builder.access

> $11(cameraInfoProto.java:238)

>        at classes.cameraInfoProto

> $camera.parseFrom(cameraInfoProto.java:133)

>        at app.jSockets.FetcherSockets

> $ResponseThread.readMessage(FetcherSockets.java:386)

>        at app.jSockets.FetcherSockets

> $ResponseThread.run(FetcherSockets.java:268)

>

>

> I double-checked my code, but I have only a single required field, and

> I’m always filling it up in the C++ app.

Just a wild guess: is it an enumeration field that you extended

recently ? If you set the new value in the C++ app, but the Java code

is still compiled with the old version that does not know about that

enumeration value, that non-matching enum field is stashed away in an

‘unknown field’ instead of ending up in the enum which the application

might not be able to handle — thus the required field is not set.

Could it be this ?

-h

Kenton Varda

unread,

Apr 19, 2010, 9:51:14 PM4/19/10

to SyRenity, Protocol Buffers

If Henner’s answer didn’t help, you’ll need to provide a small, self-contained example which reproduces the problem.

Patrick Linehan

unread,

Mar 11, 2015, 4:09:30 AM3/11/15

to prot…@googlegroups.com, stas….@gmail.com

Nearly 5 years later, I found myself having the same problem.  Perfectly-valid serialized protobufs generated in C++ for message types with no required fields suddenly started throwing «InvalidProtocolBufferException: Message was missing required fields.» exceptions in Java.

The problem is, as far as I can tell, a bug in the Dalvik JIT.  I’ve never seen in in ARM devices, but have seen it in x86 on Android 4.4.4.  Disabling the JIT (setting «android:vmSafeMode» to true in the AndroidManifest.xml) resolves the problem.

It all comes down to a sign extension bug in the following code:

 private byte memoizedIsInitialized = -1;
    public final boolean isInitialized() {
      byte isInitialized = memoizedIsInitialized;
      if (isInitialized != -1) return isInitialized == 1;

      memoizedIsInitialized = 1;
      return true;
    }

The value of isInitialized will be implicitly converted to an int (for comparison to -1 and 1) and, in certain cases, won’t be sign extended, giving a value of 255.  This in turn causes the function to return false.  This bug appears to be completely random, and doesn’t require racing threads.  I don’t know if this bug is during the initial store of the field or in the subsequent load, exactly.

A simple workaround is to modify the compiler output to make both memoizedIsInitialized and isInitalized into ints. This avoids any need for casting or sign extension.

Stephen Tu

unread,

Mar 11, 2015, 9:33:58 AM3/11/15

to Patrick Linehan, prot…@googlegroups.com, stas….@gmail.com

Patrick Linehan

unread,

Mar 11, 2015, 7:57:02 PM3/11/15

to prot…@googlegroups.com, plin…@gmail.com, stas….@gmail.com, tu.st…@gmail.com

Sorry, I spoke imprecisely.  I did not actually modify the compiler, I just run the resultant code through sed to make some fixups.

In the case where you _do_ have required fields, however, there is additional code in this function which sometimes sets the field to zero, so such a simple sed solution wouldn’t work if you used a boolean.

My intention was not (and is not) to be prescriptive about the solution.  I was just hoping to help any poor souls who encountered the same issue.

Neil Young

unread,

Oct 3, 2016, 9:00:58 PM10/3/16

to Protocol Buffers, stas….@gmail.com, plin…@gmail.com

@Patrick: Wow, what a great, great find. Congratulations.

Out of the sudden my very old project came up with the same exception, without any small changed in the code made by me. But as usual Android Studio has changed nearly every day: Updates, deprecations, changes everywhere.

I tried to come down to the reason, but the problem did not appear while I was debugging. This was the first hint which points to the JIT.

The android:vmSafeMode didn’t help BTW, seems it has now a different meaning

android:vmSafeMode
Indicates whether the app would like the virtual machine (VM) to operate in safe mode. The default value is "false".

This attribute was added in API level 8 where a value of «true» disabled the Dalvik just-in-time (JIT) compiler.

This attribute was adapted in API level 22 where a value of «true» disabled the ART ahead-of-time (AOT) compiler.

However, your second workaround is OK

Neil Young

unread,

Oct 3, 2016, 9:01:28 PM10/3/16

to Protocol Buffers, stas….@gmail.com, plin…@gmail.com

Bastien Mayard

unread,

Oct 18, 2016, 9:07:10 PM10/18/16

to Protocol Buffers, stas….@gmail.com, plin…@gmail.com

I reproduced the issue on my Nexus 6P/Android N.

It seems to be linked to InstantRun. When I disable it, code works fine. 

Feng Xiao

unread,

Oct 18, 2016, 9:08:36 PM10/18/16

to Bastien Mayard, Protocol Buffers, stas….@gmail.com, plin…@gmail.com

Понравилась статья? Поделить с друзьями:
  • Protherm ошибка f85 разблокировать котел
  • Protherm ошибка f62 pantera
  • Protherm ошибка f61
  • Protherm ошибка f28 причины
  • Protherm ошибка f27