Skip to content

Commit

Permalink
pw_rpc: Make service/method ID private in the Java APIs
Browse files Browse the repository at this point in the history
Service and method IDs are internal to pw_rpc and should not be used
externally.

Change-Id: Ia286bb9bc4b23205c84ed3d82c52132d49d7e9c3
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/97681
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Pigweed-Auto-Submit: Wyatt Hepler <hepler@google.com>
Commit-Queue: Wyatt Hepler <hepler@google.com>
  • Loading branch information
255 authored and CQ Bot Account committed Jun 10, 2022
1 parent 2c81a83 commit 88ee2e6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pw_rpc/java/main/dev/pigweed/pw_rpc/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,12 @@ public MethodClient method(int channelId, Method serviceMethod) {
return method(channelId, serviceMethod.service().id(), serviceMethod.id());
} catch (IllegalArgumentException e) {
// Rethrow the exception with the service and method name instead of the ID.
throw new IllegalArgumentException("Unknown RPC " + serviceMethod.fullName());
throw new IllegalArgumentException("Unknown RPC " + serviceMethod.fullName(), e);
}
}

/** Returns a MethodClient with the provided service and method IDs. */
public synchronized MethodClient method(int channelId, int serviceId, int methodId) {
synchronized MethodClient method(int channelId, int serviceId, int methodId) {
Channel channel = channels.get(channelId);
if (channel == null) {
throw new IllegalArgumentException("Unknown channel ID " + channelId);
Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/java/main/dev/pigweed/pw_rpc/Method.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public abstract class Method {

public abstract Class<? extends MessageLite> response();

public final int id() {
final int id() {
return Ids.calculate(name());
}

Expand Down
2 changes: 1 addition & 1 deletion pw_rpc/java/main/dev/pigweed/pw_rpc/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public String name() {
return name;
}

public int id() {
int id() {
return id;
}

Expand Down

0 comments on commit 88ee2e6

Please sign in to comment.