Copilot commented on code in PR #10223:
URL: https://github.com/apache/cloudstack/pull/10223#discussion_r2428275161


##########
server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java:
##########
@@ -1473,13 +1474,23 @@ public Counter createCounter(CreateCounterCmd cmd) {
 
         CounterVO counter = null;
 
+        CounterVO existingCounter = counterDao.findByNameProviderValue(name, 
value, provider.getName());
+        if (existingCounter != null) {
+            throw new InvalidParameterValueException(String.format("Counter 
with name %s and value %s already exists. ", name,value));

Review Comment:
   Missing space before 'value' parameter in the error message format string.
   ```suggestion
               throw new InvalidParameterValueException(String.format("Counter 
with name %s and value %s already exists. ", name, value));
   ```



##########
server/src/main/java/com/cloud/network/as/AutoScaleManagerImpl.java:
##########
@@ -1473,13 +1474,23 @@ public Counter createCounter(CreateCounterCmd cmd) {
 
         CounterVO counter = null;
 
+        CounterVO existingCounter = counterDao.findByNameProviderValue(name, 
value, provider.getName());
+        if (existingCounter != null) {
+            throw new InvalidParameterValueException(String.format("Counter 
with name %s and value %s already exists. ", name,value));
+        }
         logger.debug("Adding Counter " + name);
-        counter = counterDao.persist(new CounterVO(src, name, cmd.getValue(), 
provider));
+        counter = counterDao.persist(new CounterVO(src, name, value, 
provider));
 
         CallContext.current().setEventDetails(" Id: " + counter.getId() + " 
Name: " + name);
         return counter;
     }
 
+    @Override
+    @ActionEvent(eventType = EventTypes.EVENT_COUNTER_CREATE, eventDescription 
= "Creating a counter", async = true)
+    public Counter getCounter(long counterId) {
+        return counterDao.findById(counterId);
+    }

Review Comment:
   The getCounter method has incorrect event annotation. It should use 
EVENT_COUNTER_GET or similar since this is a read operation, not a create 
operation.



-- 
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