Skip to content

Commit 9a1b882

Browse files
committed
Findbugs issues in ApiResponseHelper fixes
1 parent 92b4f66 commit 9a1b882

3 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎api/src/com/cloud/network/rules/FirewallRule.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ enum State {
4141
Staged, // Rule been created but has never got through network rule conflict detection. Rules in this state can not be sent to network elements.
4242
Add, // Add means the rule has been created and has gone through network rule conflict detection.
4343
Active, // Rule has been sent to the network elements and reported to be active.
44-
Revoke // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
44+
Revoke, // Revoke means this rule has been revoked. If this rule has been sent to the network elements, the rule will be deleted from database.
45+
Deleting // rule has been revoked and is scheduled for deletion
4546
}
4647

4748
enum TrafficType {

‎api/src/com/cloud/network/vpc/StaticRoute.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ enum State {
2525
Staged, // route been created but has never got through network rule conflict detection. Routes in this state can not be sent to VPC virtual router.
2626
Add, // Add means the route has been created and has gone through network rule conflict detection.
2727
Active, // Route has been sent to the VPC router and reported to be active.
28-
Revoke // Revoke means this route has been revoked. If this route has been sent to the VPC router, the route will be deleted from database.
28+
Revoke, // Revoke means this route has been revoked. If this route has been sent to the VPC router, the route will be deleted from database.
29+
Deleting // rule has been revoked and is scheduled for deletion
2930
}
3031

3132
/**

‎server/src/com/cloud/api/ApiResponseHelper.java‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131

3232
import javax.inject.Inject;
3333

34+
import org.apache.log4j.Logger;
35+
3436
import org.apache.cloudstack.acl.ControlledEntity;
3537
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
3638
import org.apache.cloudstack.affinity.AffinityGroup;
@@ -146,7 +148,6 @@
146148
import org.apache.cloudstack.usage.Usage;
147149
import org.apache.cloudstack.usage.UsageService;
148150
import org.apache.cloudstack.usage.UsageTypes;
149-
import org.apache.log4j.Logger;
150151

151152
import com.cloud.api.query.ViewResponseHelper;
152153
import com.cloud.api.query.vo.AccountJoinVO;
@@ -285,7 +286,6 @@
285286
import com.cloud.utils.Pair;
286287
import com.cloud.utils.StringUtils;
287288
import com.cloud.utils.db.EntityManager;
288-
import com.cloud.utils.exception.CloudRuntimeException;
289289
import com.cloud.utils.net.Ip;
290290
import com.cloud.utils.net.NetUtils;
291291
import com.cloud.vm.ConsoleProxyVO;
@@ -387,7 +387,7 @@ public ResourceLimitResponse createResourceLimitResponse(ResourceLimit limit) {
387387
}
388388
resourceLimitResponse.setResourceType(Integer.valueOf(limit.getType().getOrdinal()).toString());
389389
if((limit.getType() == ResourceType.primary_storage || limit.getType() == ResourceType.secondary_storage) && limit.getMax() >= 0) {
390-
resourceLimitResponse.setMax((long)Math.ceil((limit.getMax() / ResourceType.bytesToGiB)));
390+
resourceLimitResponse.setMax((long)Math.ceil((double)limit.getMax() / ResourceType.bytesToGiB));
391391
} else {
392392
resourceLimitResponse.setMax(limit.getMax());
393393
}
@@ -1951,8 +1951,6 @@ public AsyncJobResponse createAsyncJobResponse(AsyncJob job) {
19511951
public SecurityGroupResponse createSecurityGroupResponseFromSecurityGroupRule(List<? extends SecurityRule> securityRules) {
19521952
SecurityGroupResponse response = new SecurityGroupResponse();
19531953
Map<Long, Account> securiytGroupAccounts = new HashMap<Long, Account>();
1954-
Map<Long, SecurityGroup> allowedSecurityGroups = new HashMap<Long, SecurityGroup>();
1955-
Map<Long, Account> allowedSecuriytGroupAccounts = new HashMap<Long, Account>();
19561954

19571955
if ((securityRules != null) && !securityRules.isEmpty()) {
19581956
SecurityGroupJoinVO securityGroup = ApiDBUtils.findSecurityGroupViewById(securityRules.get(0).getSecurityGroupId()).get(0);
@@ -3137,11 +3135,10 @@ public StaticRouteResponse createStaticRouteResponse(StaticRoute result) {
31373135
response.setCidr(result.getCidr());
31383136

31393137
StaticRoute.State state = result.getState();
3140-
String stateToSet = state.toString();
3141-
if (state.equals(FirewallRule.State.Revoke)) {
3142-
stateToSet = "Deleting";
3138+
if (state.equals(StaticRoute.State.Revoke)) {
3139+
state = StaticRoute.State.Deleting;
31433140
}
3144-
response.setState(stateToSet);
3141+
response.setState(state.toString());
31453142
populateAccount(response, result.getAccountId());
31463143
populateDomain(response, result.getDomainId());
31473144

@@ -3629,11 +3626,11 @@ public ApplicationLoadBalancerResponse createLoadBalancerContainerReponse(Applic
36293626
ApplicationLoadBalancerRuleResponse ruleResponse = new ApplicationLoadBalancerRuleResponse();
36303627
ruleResponse.setInstancePort(lb.getDefaultPortStart());
36313628
ruleResponse.setSourcePort(lb.getSourcePortStart());
3632-
String stateToSet = lb.getState().toString();
3629+
FirewallRule.State stateToSet = lb.getState();
36333630
if (stateToSet.equals(FirewallRule.State.Revoke)) {
3634-
stateToSet = "Deleting";
3631+
stateToSet = FirewallRule.State.Deleting;
36353632
}
3636-
ruleResponse.setState(stateToSet);
3633+
ruleResponse.setState(stateToSet.toString());
36373634
ruleResponse.setObjectName("loadbalancerrule");
36383635
ruleResponses.add(ruleResponse);
36393636
lbResponse.setLbRules(ruleResponses);

0 commit comments

Comments
 (0)