diff --git a/README.md b/README.md index 164145d8c011..687e4791e979 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -gRPC-Java - An RPC library and framework + gRPC-Java - An RPC library and framework ======================================== gRPC-Java works with JDK 7. gRPC-Java clients are supported on Android API diff --git a/api/src/main/java/io/grpc/MethodDescriptor.java b/api/src/main/java/io/grpc/MethodDescriptor.java index a1712bbf9499..500755de8e4c 100644 --- a/api/src/main/java/io/grpc/MethodDescriptor.java +++ b/api/src/main/java/io/grpc/MethodDescriptor.java @@ -42,7 +42,6 @@ public final class MethodDescriptor { private final MethodType type; private final String fullMethodName; @Nullable private final String serviceName; - @Nullable private final String methodName; private final Marshaller requestMarshaller; private final Marshaller responseMarshaller; private final @Nullable Object schemaDescriptor; @@ -226,7 +225,6 @@ private MethodDescriptor( this.type = Preconditions.checkNotNull(type, "type"); this.fullMethodName = Preconditions.checkNotNull(fullMethodName, "fullMethodName"); this.serviceName = extractFullServiceName(fullMethodName); - this.methodName = extractMethodName(fullMethodName); this.requestMarshaller = Preconditions.checkNotNull(requestMarshaller, "requestMarshaller"); this.responseMarshaller = Preconditions.checkNotNull(responseMarshaller, "responseMarshaller"); this.schemaDescriptor = schemaDescriptor; @@ -271,8 +269,8 @@ public String getServiceName() { */ @Nullable @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5635") - public String getMethodName() { - return methodName; + public String getBareMethodName() { + return extractBareMethodName(fullMethodName); } /** @@ -418,7 +416,8 @@ public static String extractFullServiceName(String fullMethodName) { * @since 1.32.0 */ @Nullable - public static String extractMethodName(String fullMethodName) { + @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5635") + public static String extractBareMethodName(String fullMethodName) { int index = checkNotNull(fullMethodName, "fullMethodName").lastIndexOf('/'); if (index == -1) { return null; diff --git a/api/src/test/java/io/grpc/MethodDescriptorTest.java b/api/src/test/java/io/grpc/MethodDescriptorTest.java index 4fdf10778f7a..ec89976a0164 100644 --- a/api/src/test/java/io/grpc/MethodDescriptorTest.java +++ b/api/src/test/java/io/grpc/MethodDescriptorTest.java @@ -178,36 +178,36 @@ public void getServiceName_returnsNull() { } @Test - public void getMethodName_extractsMethod() { + public void getBareMethodName_extractsMethod() { Marshaller marshaller = TestMethodDescriptors.voidMarshaller(); MethodDescriptor md = MethodDescriptor.newBuilder(marshaller, marshaller) .setType(MethodType.UNARY) .setFullMethodName("foo/bar") .build(); - assertEquals("bar", md.getMethodName()); + assertEquals("bar", md.getBareMethodName()); } @Test - public void getMethodName_returnsNull() { + public void getBareMethodName_returnsNull() { Marshaller marshaller = TestMethodDescriptors.voidMarshaller(); MethodDescriptor md = MethodDescriptor.newBuilder(marshaller, marshaller) .setType(MethodType.UNARY) .setFullMethodName("foo-bar") .build(); - assertNull(md.getMethodName()); + assertNull(md.getBareMethodName()); } @Test - public void getMethodName_returnsEmptyStringWithMethodMissing() { + public void getBareMethodName_returnsEmptyStringWithMethodMissing() { Marshaller marshaller = TestMethodDescriptors.voidMarshaller(); MethodDescriptor md = MethodDescriptor.newBuilder(marshaller, marshaller) .setType(MethodType.UNARY) .setFullMethodName("foo/") .build(); - assertTrue(md.getMethodName().isEmpty()); + assertTrue(md.getBareMethodName().isEmpty()); } @Test