Skip to content
Prev Previous commit
Next Next commit
lint fixes
  • Loading branch information
rajatbhatta committed Mar 1, 2023
commit 355f794d80f768ec2d3f39dc133dbfb82b00a12c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ public enum RpcPriority {
this.proto = Preconditions.checkNotNull(proto);
}

public static RpcPriority fromProto(Priority proto){
for(RpcPriority e : RpcPriority.values()){
if(e.proto.equals(proto)) return e;
public static RpcPriority fromProto(Priority proto) {
for (RpcPriority e : RpcPriority.values()) {
if (e.proto.equals(proto)) return e;
}
return null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's preferred to not return nulls and instead return some modelled type like UNRECOGNIZED/UNKNOWN/UNSPECIFIED. With nulls, the client does not have a good way to know underlying reason i.e invalid enum type being the actual issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a RpcPriority.UNSPECIFIED to enum to map to Priority.PRIORITY_UNSPECIFIED. If a null value is passed in, we would return RpcPriority.UNSPECIFIED.

}
Expand Down