Skip to content

Commit dda2820

Browse files
committed
Fixed Coverity reported type issues
1 parent bf9036c commit dda2820

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public Long getSourceIpAddressId() {
177177
@Override
178178
public Integer getSourcePortStart() {
179179
if (publicStartPort != null) {
180-
return publicStartPort.intValue();
180+
return publicStartPort;
181181
}
182182
return null;
183183
}
@@ -186,10 +186,10 @@ public Integer getSourcePortStart() {
186186
public Integer getSourcePortEnd() {
187187
if (publicEndPort == null) {
188188
if (publicStartPort != null) {
189-
return publicStartPort.intValue();
189+
return publicStartPort;
190190
}
191191
} else {
192-
return publicEndPort.intValue();
192+
return publicEndPort;
193193
}
194194

195195
return null;
@@ -247,11 +247,12 @@ public void create() {
247247
}
248248
}
249249
}
250-
251250
try {
252251
FirewallRule result = _firewallService.createIngressFirewallRule(this);
253-
setEntityId(result.getId());
254-
setEntityUuid(result.getUuid());
252+
if (result != null) {
253+
setEntityId(result.getId());
254+
setEntityUuid(result.getUuid());
255+
}
255256
} catch (NetworkRuleConflictException ex) {
256257
s_logger.info("Network rule conflict: " + ex.getMessage());
257258
s_logger.trace("Network Rule Conflict: ", ex);

engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
3838
xid = rule.getXid();
3939
uuid = rule.getUuid();
4040
protocol = rule.getProtocol();
41-
portStart = rule.getSourcePortStart();
42-
portEnd = rule.getSourcePortEnd();
41+
portStart = rule.getSourcePortStart().intValue();
42+
portEnd = rule.getSourcePortEnd().intValue();
4343
state = rule.getState();
4444
accountId = rule.getAccountId();
4545
domainId = rule.getDomainId();

server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
363363
for (FirewallRule vpnFwRule : vpnFwRules) {
364364
_rulesDao.remove(vpnFwRule.getId());
365365
s_logger.debug("Successfully removed firewall rule with ip id=" + vpnFwRule.getSourceIpAddressId() + " and port " +
366-
vpnFwRule.getSourcePortStart() + " as a part of vpn cleanup");
366+
vpnFwRule.getSourcePortStart().intValue() + " as a part of vpn cleanup");
367367
}
368368
}
369369
}

server/src/org/apache/cloudstack/network/lb/ApplicationLoadBalancerManagerImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public ApplicationLoadBalancerRuleVO doInTransaction(TransactionStatus status) t
185185
throw new CloudRuntimeException("Unable to update the state to add for " + newRule);
186186
}
187187
s_logger.debug("Load balancer " + newRule.getId() + " for Ip address " + newRule.getSourceIp().addr() + ", source port " +
188-
newRule.getSourcePortStart() + ", instance port " + newRule.getDefaultPortStart() + " is added successfully.");
188+
newRule.getSourcePortStart().intValue() + ", instance port " + newRule.getDefaultPortStart() + " is added successfully.");
189189
CallContext.current().setEventDetails("Load balancer Id: " + newRule.getId());
190190
Network ntwk = _networkModel.getNetwork(newRule.getNetworkId());
191191
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_LOAD_BALANCER_CREATE, newRule.getAccountId(), ntwk.getDataCenterId(), newRule.getId(), null,
@@ -527,8 +527,8 @@ protected void detectInternalLbRulesConflict(ApplicationLoadBalancerRule newLbRu
527527
(newLbRule.getSourcePortStart().intValue() <= lbRule.getSourcePortEnd().intValue() && newLbRule.getSourcePortEnd().intValue() >= lbRule.getSourcePortEnd()
528528
.intValue())) {
529529

530-
throw new NetworkRuleConflictException("The range specified, " + newLbRule.getSourcePortStart() + "-" + newLbRule.getSourcePortEnd() +
531-
", conflicts with rule " + lbRule.getId() + " which has " + lbRule.getSourcePortStart() + "-" + lbRule.getSourcePortEnd());
530+
throw new NetworkRuleConflictException("The range specified, " + newLbRule.getSourcePortStart().intValue() + "-" + newLbRule.getSourcePortEnd().intValue() +
531+
", conflicts with rule " + lbRule.getId() + " which has " + lbRule.getSourcePortStart().intValue() + "-" + lbRule.getSourcePortEnd().intValue());
532532
}
533533
}
534534

0 commit comments

Comments
 (0)