Skip to content

Commit

Permalink
Fix java:S4973 - use equals() to compare boxed types
Browse files Browse the repository at this point in the history
  • Loading branch information
cbosdo committed Oct 10, 2023
1 parent 31c8ff8 commit 2089082
Show file tree
Hide file tree
Showing 12 changed files with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ public boolean aclTrustChannelAccess(Map<String, Object> ctx, String[] params) {
Long cid = getAsLong(ctx.get("cid"));
Channel c = ChannelFactory.lookupById(cid);

return c.getOrg().getId() == user.getOrg().getId();
return c.getOrg().getId().equals(user.getOrg().getId());
}

/**
Expand Down
2 changes: 1 addition & 1 deletion java/code/src/com/redhat/rhn/domain/audit/ScapFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static XccdfTestResult lookupTestResultById(Long xid) {
*/
public static XccdfTestResult lookupTestResultByIdAndSid(Long xid, Long sid) {
XccdfTestResult result = lookupTestResultById(xid);
if (result == null || result.getServer().getId() != sid) {
if (result == null || !result.getServer().getId().equals(sid)) {
LocalizationService ls = LocalizationService.getInstance();
throw new LookupException("Could not find XCCDF scan " + xid + " for system " + sid,
ls.getMessage("lookup.xccdfscan.title"), null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ public ActionForward execute(ActionMapping mapping,
for (RhnSetElement element : groupSet.getElements()) {
Long gid = element.getElement();
if (groupMap.containsKey(gid)) {
if (element.getElementTwo() == SSMGroupManageAction.ADD) {
if (element.getElementTwo().equals(SSMGroupManageAction.ADD)) {
addList.add(groupMap.get(gid));
}
else if (element.getElementTwo() == SSMGroupManageAction.REMOVE) {
else if (element.getElementTwo().equals(SSMGroupManageAction.REMOVE)) {
removeList.add(groupMap.get(gid));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ public final ActionForward execute(ActionMapping mapping,
throw new BadParameterException("Missing min, max and/or ksid for ks ip range");
}
// make sure org has permission
else if (user.getOrg().getId() !=
cmd.getKickstartData().getOrg().getId()) {
else if (!user.getOrg().getId().equals(cmd.getKickstartData().getOrg().getId())) {
throw new BadParameterException("Invalid uid for /rhn/kickstart/");
}
// delete ip range from kickstart
Expand All @@ -80,7 +79,7 @@ else if (user.getOrg().getId() !=
request.getParameter(MIN),
request.getParameter(MAX));
if (success) {
createSuccessMessage(request, getSuccessKey(),
createSuccessMessage(request, "kickstart.iprange_delete.success",
cmd.getKickstartData().getLabel());
}
else {
Expand All @@ -97,13 +96,4 @@ else if (user.getOrg().getId() !=
return strutsDelegate.forwardParams(mapping.findForward(RhnHelper.DEFAULT_FORWARD),
params);
}

/**
*
* @return i18n key
*/
private String getSuccessKey() {
return "kickstart.iprange_delete.success";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public ActionForward execute(ActionMapping mapping,
ActionForward retval = mapping.findForward(RhnHelper.DEFAULT_FORWARD);

// protect self from removing sat admin role
if (current.getId() == u.getId()) {
if (current.getId().equals(u.getId())) {
//make sure we always have at least one sat admin
if (SatManager.getActiveSatAdmins().size() == 1) {
createErrorMessage(request, "satadmin.jsp.error.lastsatadmin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ else if (daForm.get(AUTO_UPDATE) == null) {

// Set the contact method
Long contactId = (Long) daForm.get(CONTACT_METHOD);
if (contactId != null && (contactId != s.getContactMethod().getId()) &&
!s.asMinionServer().isPresent()) {
if (contactId != null && !contactId.equals(s.getContactMethod().getId()) &&
s.asMinionServer().isEmpty()) {
s.setContactMethod(ServerFactory.findContactMethodById(contactId));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public List<RuleResultComparator> getData() {
public List<RuleResultComparator> getData(Boolean differs) {
List<RuleResultComparator> result = new ArrayList<>();
for (RuleResultComparator item : dataMap.values()) {
if (item.getDiffers() == differs) {
if (item.getDiffers().equals(differs)) {
result.add(item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void removeTokensByIds(List<Long> ids) {
Set<Token> tokenSetCopy = new HashSet<>();
tokenSetCopy.addAll(this.getKickstartData().getDefaultRegTokens());
for (Token token : tokenSetCopy) {
if (token.getId() == id) {
if (token.getId().equals(id)) {
this.getKickstartData().getDefaultRegTokens().remove(token);
keysToRemove.add(ActivationKeyFactory.lookupByToken(token).getKey());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public long storeMirrorCredentials(MirrorCredentialsDto creds,
// Check if the supplied user name already exists in stored credentials
for (Credentials existingCred : CredentialsFactory.listSCCCredentials()) {
if (existingCred.getUsername().equals(creds.getUser()) &&
(creds.getId() != existingCred.getId())) {
(!creds.getId().equals(existingCred.getId()))) {
throw new MirrorCredentialsNotUniqueException("Username already exists");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3699,7 +3699,7 @@ public static void setUserSystemPreferenceBulk(User user, String preference,
params.put("pref", preference);
mode.execute(params, new HashMap<>());
// preference values have a default, only insert if not default
if (value != defaultIn) {
if (!value.equals(defaultIn)) {
mode = ModeFactory.getCallableMode("System_queries",
"set_user_system_preference_bulk");
params = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ private List<Long> invalidateActionRecursive(Long serverId, Long actionId) {
Server s = ServerFactory.lookupById(serverId);
Action a = ActionFactory.lookupById(actionId);
ServerAction sa = ActionFactory.getServerActionForServerAndAction(s, a);
if (sa.getStatus().getName() != "Failed") {
if (!"Failed".equals(sa.getStatus().getName())) {
sa.fail(-100L, "Prerequisite failed", sa.getPickupTime());

s.asMinionServer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public static String updateFiltersOfProject(Request req, Response res, User user
.filter(filterId ->
!dbContentProject.getProjectFilters()
.stream()
.filter(filter -> filter.getId() == filterId)
.filter(filter -> filter.getId().equals(filterId))
.findFirst()
.isPresent()
)
Expand Down

0 comments on commit 2089082

Please sign in to comment.