let's say I have the following mode.proto file:
message EntityD {
optional EntityE ePointer = 1;
optional int32 dField = 2;
}
message EntityE {
optional EntityD dPointer = 1;
optional int32 eField = 2;
}
it has 2 entities - D and E, which allow stitching. my problem is that after generating java code from the above * .proto im could not create a loop:
public static void main(String[] args) throws Exception {
Model.EntityD.Builder dBuilder = Model.EntityD.newBuilder();
Model.EntityE.Builder eBuilder = Model.EntityE.newBuilder();
dBuilder.setDField(42);
eBuilder.setEField(7);
dBuilder.setEPointer(eBuilder);
eBuilder.setDPointer(dBuilder);
Model.EntityD d = dBuilder.build();
Model.EntityE e = eBuilder.build();
System.err.println("same d: "+(d==e.getDPointer()));
System.err.println("same e: "+(e==d.getEPointer()));
}
im trying to create a simple cycle D β E. Instead, I get the following:
same d: false
same e: false

In the created model there is a cycle, but only starting from a certain depth.
is a problem with probuf generated java code? Does protobuf really support loops on the chart? What is the expected result for this in other "output" protobuff languages? (namely C ++)
source
share