Commit 5c017b62 by Juho Juopperi

Merge branch 'findbugs' into 'master'

Findbugs

Few bufgixes found by Findbugs-eclipse plugin. (You should try it too!)

NOTE! This should only be accepted after ee7 MR
2 parents 0c146470 5443d00e
...@@ -107,7 +107,7 @@ public class ReaderBean implements ReaderBeanLocal { ...@@ -107,7 +107,7 @@ public class ReaderBean implements ReaderBeanLocal {
{ {
ReaderEvent lastevent = lastevents.get(0); ReaderEvent lastevent = lastevents.get(0);
if (lastevent.getValue() == event.getValue() && (lastevent.getUpdatetime().getTime() + 60000l) > event.getTime().getTime()) { if (lastevent.getValue().equals(event.getValue()) && (lastevent.getUpdatetime().getTime() + 60000l) > event.getTime().getTime()) {
lastevent = readerEventFacade.reload(lastevent); lastevent = readerEventFacade.reload(lastevent);
lastevent = readerEventFacade.merge(lastevent); lastevent = readerEventFacade.merge(lastevent);
......
...@@ -979,7 +979,7 @@ public class UserBean implements UserBeanLocal { ...@@ -979,7 +979,7 @@ public class UserBean implements UserBeanLocal {
logger.info("Catched exeption {}", ex.getMessage()); logger.info("Catched exeption {}", ex.getMessage());
} }
if (hash != "" && hash.length() > 2) { if (!hash.isEmpty() && hash.length() > 2) {
// Generating code by concatenating hex string and first 3 // Generating code by concatenating hex string and first 3
// characters from hash // characters from hash
code = code.concat(hex); code = code.concat(hex);
......
...@@ -52,13 +52,12 @@ public class JsonUtils { ...@@ -52,13 +52,12 @@ public class JsonUtils {
* The value associate to the key * The value associate to the key
* @return JsonObject with the key:value pair added * @return JsonObject with the key:value pair added
*/ */
public static JsonObject assocJsonObject(JsonObject jsonObject, String key, public static JsonObject assocJsonObject(JsonObject jsonObject, String key, JsonValue value) {
JsonValue value) {
JsonObjectBuilder builder = Json.createObjectBuilder(); JsonObjectBuilder builder = Json.createObjectBuilder();
// Copy all non conflicting json entries // Copy all non conflicting json entries
for (Map.Entry<String, JsonValue> v : jsonObject.entrySet()) { for (Map.Entry<String, JsonValue> v : jsonObject.entrySet()) {
if (v.getKey() != key) { if (v.getKey().equals(key)) {
builder = builder.add(v.getKey(), v.getValue()); builder = builder.add(v.getKey(), v.getValue());
} }
} }
......
...@@ -50,7 +50,7 @@ public class NetworkAssociationRestView { ...@@ -50,7 +50,7 @@ public class NetworkAssociationRestView {
resp.getPendings().add(new NetworkAssociationActionPojo(na.getIP(), na.getMAC())); resp.getPendings().add(new NetworkAssociationActionPojo(na.getIP(), na.getMAC()));
} catch(Exception e) { } catch(Exception e) {
resp.getResult().setResultCode(0); resp.getResult().setResultCode(0);
if(e.getMessage() != null && e.getMessage() != "") { if(e.getMessage() != null && !e.getMessage().isEmpty()) {
resp.getResult().setMessage(e.getMessage()); resp.getResult().setMessage(e.getMessage());
} else { } else {
resp.getResult().setMessage("UNKNOWN_ERROR"); resp.getResult().setMessage("UNKNOWN_ERROR");
...@@ -81,7 +81,7 @@ public class NetworkAssociationRestView { ...@@ -81,7 +81,7 @@ public class NetworkAssociationRestView {
resp.getPendings().add(new NetworkAssociationActionPojo(na.getIP(), na.getMAC())); resp.getPendings().add(new NetworkAssociationActionPojo(na.getIP(), na.getMAC()));
} catch(Exception e) { } catch(Exception e) {
resp.getResult().setResultCode(0); resp.getResult().setResultCode(0);
if(e.getMessage() != null && e.getMessage() != "") { if(e.getMessage() != null && !e.getMessage().isEmpty()) {
resp.getResult().setMessage(e.getMessage()); resp.getResult().setMessage(e.getMessage());
} else { } else {
resp.getResult().setMessage("UNKNOWN_ERROR"); resp.getResult().setMessage("UNKNOWN_ERROR");
......
...@@ -284,7 +284,7 @@ public class ReaderView extends GenericCDIView { ...@@ -284,7 +284,7 @@ public class ReaderView extends GenericCDIView {
if(lastReadEvent == null || lastReadEvent.getId() == null) if(lastReadEvent == null || lastReadEvent.getId() == null)
return true; return true;
return (newEvent.getId() != lastReadEvent.getId()); return (newEvent.getId().equals(lastReadEvent.getId()));
} }
......
...@@ -113,7 +113,7 @@ public class LectureReportsView extends GenericCDIView { ...@@ -113,7 +113,7 @@ public class LectureReportsView extends GenericCDIView {
// sometimes you just are lazy // sometimes you just are lazy
for(EventUser user : getCurrentLecture().getParticipants()) { for(EventUser user : getCurrentLecture().getParticipants()) {
if(user.getId() == userId) { if(user.getId().equals(userId)) {
lectureBean.unparticipate(user, getCurrentLecture()); lectureBean.unparticipate(user, getCurrentLecture());
break; break;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!