Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes MethodDescriptor java documentation #9860

Merged
merged 1 commit into from
Feb 2, 2023
Merged

Fixes MethodDescriptor java documentation #9860

merged 1 commit into from
Feb 2, 2023

Conversation

antechrestos
Copy link
Contributor

@antechrestos antechrestos commented Jan 27, 2023

According to git history, method 'getBareMethodName' and 'extractBareMethodName' of MethodDescriptor appeared in 1.33.0

See 1.32.0 source version

Here is the diff between 1.32.0 and 1.33.0

@@ -262,6 +262,17 @@ public final class MethodDescriptor<ReqT, RespT> {
     return serviceName;
   }
 
+  /**
+   * A convenience method for {@code extractBareMethodName(getFullMethodName())}.
+   *
+   * @since 1.32.0
+   */
+  @Nullable
+  @ExperimentalApi("https://github.com/grpc/grpc-java/issues/5635")
+  public String getBareMethodName() {
+    return extractBareMethodName(fullMethodName);
+  }
+
   /**
    * Parse a response payload from the given {@link InputStream}.
    *
@@ -398,6 +409,22 @@ public final class MethodDescriptor<ReqT, RespT> {
     return fullMethodName.substring(0, index);
   }
 
+  /**
+   * Extract the method name out of a fully qualified method name. May return {@code null}
+   * if the input is malformed, but you cannot rely on it for the validity of the input.
+   *
+   * @since 1.32.0
+   */
+  @Nullable
+  @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;
+    }
+    return fullMethodName.substring(index + 1);
+  }
+
   /**
    * Creates a new builder for a {@link MethodDescriptor}.
    *

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jan 27, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: antechrestos / name: Benjamin Einaudi (d4f1762)

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

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

Suggested one more similar change for the same fix

According to git history, method 'getBareMethodName' and 'extractBareMethodName' of MethodDescriptor appeared in 1.33.0
@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Feb 2, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: antechrestos / name: Benjamin Einaudi (269c6e2)

@antechrestos
Copy link
Contributor Author

suggestion made

Copy link
Contributor

@sanjaypujare sanjaypujare left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

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

Ah, yep, it ended up being merged after the branch cut.

@ejona86 ejona86 added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 2, 2023
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Feb 2, 2023
@ejona86 ejona86 enabled auto-merge (rebase) February 2, 2023 20:20
@ejona86
Copy link
Member

ejona86 commented Feb 2, 2023

Thank you!

@ejona86 ejona86 merged commit fb70a66 into grpc:master Feb 2, 2023
@antechrestos antechrestos deleted the fixes/method-descriptor-documentation branch February 3, 2023 08:42
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants