Skip to content

Commit dcda79e

Browse files
DaanHooglandDaan Hoogland
authored andcommitted
Findbugs: different issues solved
1 parent 1fb32b5 commit dcda79e

9 files changed

Lines changed: 97 additions & 75 deletions

File tree

server/src/com/cloud/api/query/vo/UserVmJoinVO.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.cloud.storage.Storage.StoragePoolType;
3636
import com.cloud.storage.Volume;
3737
import com.cloud.utils.db.GenericDao;
38+
import com.cloud.utils.exception.CloudRuntimeException;
3839
import com.cloud.vm.VirtualMachine;
3940
import com.cloud.vm.VirtualMachine.State;
4041

@@ -47,10 +48,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
4748
private long id;
4849

4950
@Column(name="name", updatable=false, nullable=false, length=255)
50-
private String name = null;
51+
private final String name = null;
5152

5253
@Column(name="display_name", updatable=false, nullable=false, length=255)
53-
private String displayName = null;
54+
private final String displayName = null;
5455

5556
@Column(name="account_id")
5657
private long accountId;
@@ -59,7 +60,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
5960
private String accountUuid;
6061

6162
@Column(name="account_name")
62-
private String accountName = null;
63+
private final String accountName = null;
6364

6465
@Column(name="account_type")
6566
private short accountType;
@@ -71,10 +72,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
7172
private String domainUuid;
7273

7374
@Column(name="domain_name")
74-
private String domainName = null;
75+
private final String domainName = null;
7576

7677
@Column(name="domain_path")
77-
private String domainPath = null;
78+
private final String domainPath = null;
7879

7980
@Column(name="instance_group_id")
8081
private long instanceGroupId;
@@ -96,7 +97,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
9697
*/
9798
@Enumerated(value=EnumType.STRING)
9899
@Column(name="state", updatable=true, nullable=false, length=32)
99-
private State state = null;
100+
private final State state = null;
100101

101102
@Column(name=GenericDao.CREATED_COLUMN)
102103
private Date created;
@@ -149,7 +150,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
149150
private String dataCenterUuid;
150151

151152
@Column(name="data_center_name")
152-
private String dataCenterName = null;
153+
private final String dataCenterName = null;
153154

154155
@Column(name="security_group_enabled")
155156
private boolean securityGroupEnabled;
@@ -225,7 +226,7 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
225226
private String volume_uuid;
226227

227228
@Column(name = "volume_device_id")
228-
private Long volumeDeviceId = null;
229+
private final Long volumeDeviceId = null;
229230

230231
@Column(name = "volume_type")
231232
@Enumerated(EnumType.STRING)
@@ -726,9 +727,11 @@ public Map<String, String> getDetails() {
726727
}
727728

728729
public String getDetail(String name) {
729-
assert (details != null) : "Did you forget to load the details?";
730+
if (details == null) {
731+
throw new CloudRuntimeException("No details to get. Did you forget to load the details?");
732+
}
730733

731-
return details != null ? details.get(name) : null;
734+
return details.get(name);
732735
}
733736

734737
public String getUserData() {

server/src/com/cloud/consoleproxy/AgentHookBase.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
import org.apache.log4j.Logger;
2424

25+
import com.google.gson.Gson;
26+
import com.google.gson.GsonBuilder;
27+
28+
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
29+
2530
import com.cloud.agent.AgentManager;
2631
import com.cloud.agent.api.AgentControlAnswer;
2732
import com.cloud.agent.api.Answer;
@@ -44,14 +49,10 @@
4449
import com.cloud.servlet.ConsoleProxyPasswordBasedEncryptor;
4550
import com.cloud.servlet.ConsoleProxyServlet;
4651
import com.cloud.utils.Ternary;
52+
import com.cloud.utils.exception.CloudRuntimeException;
4753
import com.cloud.vm.VirtualMachine;
4854
import com.cloud.vm.dao.VMInstanceDao;
4955

50-
import com.google.gson.Gson;
51-
import com.google.gson.GsonBuilder;
52-
53-
import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
54-
5556
/**
5657
* Utility class to manage interactions with agent-based console access
5758
* Extracted from ConsoleProxyManagerImpl so that other console proxy managers
@@ -72,12 +73,12 @@ public abstract class AgentHookBase implements AgentHook {
7273

7374
public AgentHookBase(VMInstanceDao instanceDao, HostDao hostDao, ConfigurationDao cfgDao, KeystoreManager ksMgr,
7475
AgentManager agentMgr, ManagementServer ms) {
75-
this._instanceDao = instanceDao;
76-
this._hostDao = hostDao;
77-
this._agentMgr = agentMgr;
78-
this._configDao = cfgDao;
79-
this._ksMgr = ksMgr;
80-
this._ms = ms;
76+
_instanceDao = instanceDao;
77+
_hostDao = hostDao;
78+
_agentMgr = agentMgr;
79+
_configDao = cfgDao;
80+
_ksMgr = ksMgr;
81+
_ms = ms;
8182
}
8283

8384
@Override
@@ -204,7 +205,9 @@ public void startAgentHttpHandlerInVM(StartupProxyCommand startupCmd) {
204205

205206
assert (ksBits != null);
206207
if (ksBits == null) {
207-
s_logger.error("Could not find and construct a valid SSL certificate");
208+
String msg = "Could not find and construct a valid SSL certificate";
209+
s_logger.error(msg);
210+
throw new CloudRuntimeException(msg);
208211
}
209212
cmd = new StartConsoleProxyAgentHttpHandlerCommand(ksBits, storePassword);
210213
cmd.setEncryptorPassword(getEncryptorPassword());

server/src/com/cloud/consoleproxy/ConsoleProxyManagerImpl.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -970,11 +970,7 @@ public boolean isZoneReady(Map<Long, ZoneHostInfo> zoneHostInfoMap, long dataCen
970970
}
971971
} else {
972972
if (s_logger.isDebugEnabled()) {
973-
if (template == null) {
974-
s_logger.debug("Zone host is ready, but console proxy template is null");
975-
} else {
976-
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
977-
}
973+
s_logger.debug("Zone host is ready, but console proxy template: " + template.getId() + " is not ready on secondary storage.");
978974
}
979975
}
980976
}

server/src/com/cloud/dc/DedicatedResourceVO.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
import javax.persistence.Column;
2222
import javax.persistence.Entity;
23-
2423
import javax.persistence.GeneratedValue;
2524
import javax.persistence.GenerationType;
2625
import javax.persistence.Id;
@@ -31,6 +30,11 @@
3130
@Table(name="dedicated_resources")
3231
public class DedicatedResourceVO implements DedicatedResources{
3332

33+
/**
34+
*
35+
*/
36+
private static final long serialVersionUID = -6659510127145101917L;
37+
3438
@Id
3539
@GeneratedValue(strategy = GenerationType.IDENTITY)
3640
@Column(name="id")
@@ -61,7 +65,7 @@ public class DedicatedResourceVO implements DedicatedResources{
6165
private long affinityGroupId;
6266

6367
public DedicatedResourceVO() {
64-
this.uuid = UUID.randomUUID().toString();
68+
uuid = UUID.randomUUID().toString();
6569
}
6670

6771
public DedicatedResourceVO(Long dataCenterId, Long podId, Long clusterId, Long hostId, Long domainId,
@@ -72,14 +76,16 @@ public DedicatedResourceVO(Long dataCenterId, Long podId, Long clusterId, Long h
7276
this.hostId = hostId;
7377
this.domainId = domainId;
7478
this.accountId = accountId;
75-
this.uuid = UUID.randomUUID().toString();
79+
uuid = UUID.randomUUID().toString();
7680
this.affinityGroupId = affinityGroupId;
7781
}
7882

83+
@Override
7984
public long getId() {
8085
return id;
8186
}
8287

88+
@Override
8389
public Long getDataCenterId() {
8490
return dataCenterId;
8591
}
@@ -88,6 +94,7 @@ public void setDataCenterId(long dataCenterId) {
8894
this.dataCenterId = dataCenterId;
8995
}
9096

97+
@Override
9198
public Long getPodId() {
9299
return podId;
93100
}
@@ -96,6 +103,7 @@ public void setPodId(long podId) {
96103
this.podId = podId;
97104
}
98105

106+
@Override
99107
public Long getClusterId() {
100108
return clusterId;
101109
}
@@ -104,6 +112,7 @@ public void setClusterId(long clusterId) {
104112
this.clusterId = clusterId;
105113
}
106114

115+
@Override
107116
public Long getHostId() {
108117
return hostId;
109118
}
@@ -113,9 +122,10 @@ public void setHostId(long hostId) {
113122
}
114123

115124
public DedicatedResourceVO(long dedicatedResourceId) {
116-
this.id = dedicatedResourceId;
125+
id = dedicatedResourceId;
117126
}
118127

128+
@Override
119129
public Long getDomainId() {
120130
return domainId;
121131
}
@@ -124,6 +134,7 @@ public void setDomainId(Long domainId) {
124134
this.domainId = domainId;
125135
}
126136

137+
@Override
127138
public Long getAccountId() {
128139
return accountId;
129140
}
@@ -132,22 +143,24 @@ public void setAccountId(Long accountId) {
132143
this.accountId = accountId;
133144
}
134145

146+
@Override
135147
public String getUuid() {
136-
return this.uuid;
148+
return uuid;
137149
}
138150

139151
public void setUuid(String uuid) {
140152
this.uuid = uuid;
141153
}
142154

155+
@Override
143156
public long getAffinityGroupId() {
144157
return affinityGroupId;
145158
}
146159

147160
@Override
148161
public boolean equals(Object obj) {
149162
if (obj instanceof DedicatedResourceVO) {
150-
return ((DedicatedResourceVO) obj).getId() == this.getId();
163+
return ((DedicatedResourceVO) obj).getId() == getId();
151164
} else {
152165
return false;
153166
}

0 commit comments

Comments
 (0)