Coder Social home page Coder Social logo

os72 / protobuf-dynamic Goto Github PK

View Code? Open in Web Editor NEW
263.0 14.0 53.0 92 KB

Protocol Buffers Dynamic Schema - create protobuf schemas programmatically

License: Apache License 2.0

Java 100.00%
java protobuf protocol-buffers protoc protobuf-compiler schema

protobuf-dynamic's People

Contributors

dependabot[bot] avatar jhsenjaliya avatar os72 avatar rayokota avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

protobuf-dynamic's Issues

While parsing a protocol message, the input ended unexpectedly in the middle of a field.

First of all, thank you for your contribution
The problem is
I want to build protobuf schema from .proto file
I use your DynamicSchema to build schema then use the schema to parse a byte message which is generated by precompiled protobuf java class
but I get the following exception:
While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either than the input has been truncated or that an embedded message misreported its own length.

this is my code : https://github.com/cecol/protobuf-to-avro/blob/dev/src/main/java/wilber/com/transform/Main.java
is any misunderstand of your DynamicSchema or any mistake in my code?

public access for fd proto builder

both mFileDescSetBuilder and mFileDescSetBuilder is useful to be accessible too make use of it in other methods. I already have use for mFileDescProtoBuilder.
would it be possible to make it public ?

why not support FieldDescriptorProto.Type.TYPE_MESSAGE type

I found it could not support create bellow schema dynamic:

import "google/protobuf/wrappers.proto";
message TestWrapperEntity{
  google.protobuf.DoubleValue field01 = 1 [json_name="field01"];
}

Do you have some suggest how to solve this problem? Thanks

DynamicSchema.Builder fails at .build() when using protobuf-java-2.6.1

I get a NoSuchMethod exception at line 203 in Dynamic Schema:

List dependencyList = fdProto.getDependencyList();

But if I change it for:

ProtocolStringList dependencyList = fdProto.getDependencyList();

Everything works correctly. Is this normal or just my issue? I don't know if this matters but I am using Java 8.

I can do a pull request if you like with the necessary changes to get it working with protobuf-java-2.6.1 .

While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either that the input has been truncated or that an embedded message misreported its own length.

Hi,
I had written producer, consumer application, here producer thread produces messages, serializes it with protobuff and publishes it with zeroMQ publisher.
At consumer side thread will subscriber on zeroMQ port and deserializes the messsages with protobuff. I am getting below issues randomly at my consumer side while decoding protobuff byte array:
com.google.protobuf.InvalidProtocolBufferException: While parsing a protocol message, the input ended unexpectedly in the middle of a field. This could mean either that the input has been truncated or that an embedded message misreported its own length.

ProtobuffIssues12HrsTest.txt

These issues i am getting is random issue it's not that i am getting it for each and every message, out of 47,00,000 messages in 12hrs i got this issue for 10 messages, and i am testing this on a single machine.

Below is my producer proto file:-
ProtoFileProducer1.txt

Below is my producer class:-
Producer.txt

Below is my consumer proto file:-
ConsumerProtoFile.txt

Below is my consumer class:
Consumer.txt

[feature request] Java IDL for protobuf (Protocl Buffers in Java)

well, I think if it ever appear, it will come with your participation:

Java IDL for protobuf (Protocl Buffers in Java)

That is instead of

service Greeter {
  rpc SayHello (HelloRequest) returns (HelloReply) {}
}

I would like to have

public interface Greeter {
	@Grpc
	HelloReply sayHello (HelloRequest req);

}

@GrpcMessage()
public class HelloReply{
	@GrpcField(1)
	string name;
} 

That is annotation like Hibernate/JPA over my POJO, instead of heaps of generated code.

http://stackoverflow.com/questions/40425211/java-idl-for-protobuf-protocl-buffers-in-java

Infinite loop when a dependency is missing in proto file

I have the following method:

public static Descriptors.Descriptor parseProto (String protoPath, String messageType) throws IOException, Descriptors.DescriptorValidationException {
        FileInputStream schemaFile = new FileInputStream(protoPath);
        DynamicSchema schema = DynamicSchema.parseFrom(schemaFile);
        return schema.getMessageDescriptor(messageType);
    }

But when executed, the program is caught in an infinite loop in DynamicSchema.init() on line 219:

while (fileDescMap.size() < fileDescSet.getFileCount()) {

afaik, the condition is always true since fileDescMap is cleared just before and nothing is ever added into it, and fileDescSet has elements (1 in my case) which are never removed.

EDIT: I just tried with your sample schema (Schema2.desc), it is working well, but I guess it is because there is no dependency. I am personally using the example proto from Google: https://github.com/google/protobuf/blob/master/examples/addressbook.proto

EDIT 2: I finally found the problem: it came from my .proto file. If an import statement is not available (external statement), it will keep looping trying to add it to the set. It is a problem in my case as I am not aware of the proto file that will be parsed, I don't want the parser to freeze my app. Maybe throwing an exception in case of missing dependency?

A puzzle about the 2.4.1 and 2.6.1 getDependencyList API change

Hi,

There is a comment about the ProtoBuf API change in DynamicSchema.java.

// getDependencyList() signature was changed and broke compatibility in 2.6.1; workaround with reflection
//List<String> dependencyList = fdProto.getDependencyList();

link: https://github.com/os72/protobuf-dynamic/blob/master/src/main/java/com/github/os72/protobuf/dynamic/DynamicSchema.java#L223-L224

I just checked this method signature in ProtoBuf 2.4.1 and 2.6.1

In 2.4.1

public java.util.List<String> getDependencyList() {
      return dependency_;
}

in 2.6.1

public com.google.protobuf.ProtocolStringList getDependencyList() {
      return dependency_;
}

but ProtocolStringList is actually a List<String>

public interface ProtocolStringList extends List<String> {

  /** Returns a view of the data as a list of ByteStrings. */
  List<ByteString> asByteStringList();

}

So what does the broken compatibility here mean?

Thank you,
Justin

Example of how to use existing proto types

I'm trying to create a DynamicSchema that includes an existing proto message type that has been previously defined, compiled and included in my classpath. Could you show how to do that?

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.

  • 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.

  • 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.

  • D3 photo D3

    Data-Driven Documents codes.