You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
syntax = "proto3";
package protocol;
import 'src/main/swift/swift-descriptor.proto';
option (.google.protobuf.swift_file_options).entities_access_control = PublicEntities;
message Envelope {
enum Type {
CONTENT = 0;
//Added in a second version of the protocol
READ = 1;
}
}
Description
Protobuf 3 enum compatibility
Your implementation differs from the Java implementation in the following two key ways
The protoc java implementation generates an UNKNOWN value for enums and when ever an unknown type is encountered the resulting Object has this UNKNOWN value for the enum.
The protoc java implementation does not write out default values
The result of these two differences is that if I have a Swift client built using the first version of the protocol (ie without the READ value) and it receives a message from a Java client which sent the READ value that is indistinguishable from the case in which the Java client sends the CONTENT value.
It is worth noting that if all of the clients involved are using your Swift generator this ambiguity does not arise because the sender will write out the actual CONTENT value in the bytes (as opposed to the Java implementation which sends empty bytes and relies on the default object on the other side).The receiver can use the generated hasType property to differentiate the two cases if the full bytes are written.
The text was updated successfully, but these errors were encountered:
Version of protoc (
protoc --version
)libprotoc 3.0.0
Version of ProtocolBuffers.framework
ProtoBuf3.0-Swift2.0 19ac094
.proto
file to reproduceDescription
Protobuf 3 enum compatibility
Your implementation differs from the Java implementation in the following two key ways
The result of these two differences is that if I have a Swift client built using the first version of the protocol (ie without the READ value) and it receives a message from a Java client which sent the READ value that is indistinguishable from the case in which the Java client sends the CONTENT value.
It is worth noting that if all of the clients involved are using your Swift generator this ambiguity does not arise because the sender will write out the actual CONTENT value in the bytes (as opposed to the Java implementation which sends empty bytes and relies on the default object on the other side).The receiver can use the generated hasType property to differentiate the two cases if the full bytes are written.
The text was updated successfully, but these errors were encountered: