Skip to content

Commit be1cc2d

Browse files
committed
address copilot
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent 8efc627 commit be1cc2d

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

server/src/main/java/com/cloud/api/ApiServlet.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ protected boolean isStateChangingCommandNotUsingPOST(String command, String meth
498498
commandHttpMethod = at.httpMethod();
499499
}
500500
}
501-
} catch (CloudRuntimeException ignored) {}
501+
} catch (CloudRuntimeException e) {
502+
LOGGER.trace("Command class not found for {}; falling back to pattern match", command, e);
503+
}
502504
if (BaseCmd.HTTPMethod.GET.toString().equalsIgnoreCase(commandHttpMethod) ||
503505
GET_REQUEST_COMMANDS.matcher(command.toLowerCase()).matches()) {
504506
return false;

server/src/test/java/com/cloud/api/ApiServletTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
@RunWith(MockitoJUnitRunner.class)
6666
public class ApiServletTest {
6767

68+
private static final String[] STATE_CHANGING_COMMAND_CHECK_NAME_PARAM =
69+
{ApiServer.EnforcePostRequestsAndTimestamps.key()};
70+
6871
@Mock
6972
ApiServer apiServer;
7073

@@ -496,7 +499,7 @@ public void isStateChangingCommandNotUsingPOSTReturnsFalseForUpdateConfiguration
496499
String command = "updateConfiguration";
497500
String method = "GET";
498501
Map<String, Object[]> params = new HashMap<>();
499-
params.put("name", new String[] { ApiServer.EnforcePostRequestsAndTimestamps.key() });
502+
params.put("name", STATE_CHANGING_COMMAND_CHECK_NAME_PARAM);
500503
boolean result = servlet.isStateChangingCommandNotUsingPOST(command, method, params);
501504
Assert.assertFalse(result);
502505
}
@@ -506,7 +509,7 @@ public void isStateChangingCommandNotUsingPOSTReturnsFalseForWrongApiEnforcePost
506509
String command = "updateSomeApi";
507510
String method = "GET";
508511
Map<String, Object[]> params = new HashMap<>();
509-
params.put("name", new String[] { ApiServer.EnforcePostRequestsAndTimestamps.key() });
512+
params.put("name", STATE_CHANGING_COMMAND_CHECK_NAME_PARAM);
510513
boolean result = servlet.isStateChangingCommandNotUsingPOST(command, method, params);
511514
Assert.assertTrue(result);
512515
}

0 commit comments

Comments
 (0)