ezntt commented on code in PR #7022:
URL: https://github.com/apache/cloudstack/pull/7022#discussion_r1060195337


##########
api/src/main/java/org/apache/cloudstack/api/BaseCmd.java:
##########
@@ -247,30 +247,36 @@ public void setResponseType(final String responseType) {
         this.responseType = responseType;
     }
 
-    /**
-     * For some reason this method does not return the actual command name, 
but more a name that
-     * is used to create the response. So you can expect for a XCmd a value 
like xcmdresponse. Anyways
-     * this methods is used in too many places so for now instead of changing 
it we just create another
-     * method {@link BaseCmd#getActualCommandName()} that returns the value 
from {@link APICommand#name()}
-     *
-     * @return
-     */
-    public abstract String getCommandName();
-
-
     /**
      * Gets the CommandName based on the class annotations: the value from 
{@link APICommand#name()}
      *
      * @return the value from {@link APICommand#name()}
      */
-    public String getActualCommandName() {
+    public static String getCommandNameByClass(Class<?> clazz) {
         String cmdName = null;
-        if (this.getClass().getAnnotation(APICommand.class) != null) {
-            cmdName = this.getClass().getAnnotation(APICommand.class).name();
+        APICommand apiClassAnnotation = clazz.getAnnotation(APICommand.class);
+
+        if (apiClassAnnotation != null && apiClassAnnotation.name() != null) {
+            cmdName = apiClassAnnotation.name();
         } else {
-            cmdName = this.getClass().getName();
+            cmdName = clazz.getName();

Review Comment:
   @weizhouapache, I checked the code and did not find `APICommand` annotations 
with null name. Regarding the fallback to the class name, it is an already 
existing behavior, it was not introduced by this PR; therefore, if we had this 
situation, we probably would have catch it before.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to