Commit 734f9f72 by Tuomas Riihimäki

Findbugs fixes. No functional changes

1 parent 1f03debb
......@@ -23,6 +23,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Random;
import java.util.concurrent.ConcurrentHashMap;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
......@@ -92,25 +93,17 @@ public class RestBean implements RestBeanLocal {
}
// Username -> Nonce -> expiration
private Map<String, Map<String, Long>> userRestAuths = Collections.synchronizedMap(new HashMap<String, Map<String, Long>>());
private ConcurrentHashMap<String, ConcurrentHashMap<String, Long>> userRestAuths = new ConcurrentHashMap<>();
@Override
public String getLoggedinUserRestNonce()
{
public String getLoggedinUserRestNonce() {
String username = context.getCallerPrincipal().getName();
if (username == null) {
return null;
}
Map<String, Long> userAuthMap = userRestAuths.get(username);
ConcurrentHashMap<String, Long> userAuthMap = userRestAuths.get(username);
if (userAuthMap == null) {
synchronized (userRestAuths) {
if (!userRestAuths.containsKey(username)) {
userAuthMap = Collections.synchronizedMap(new HashMap<String, Long>());
userRestAuths.put(username, userAuthMap);
} else {
userRestAuths.get(username);
}
}
userAuthMap = userRestAuths.putIfAbsent(username, new ConcurrentHashMap<>());
}
Random random = new Random();
......
......@@ -156,11 +156,11 @@ public class PojoUtils {
public static ReaderEventRestPojo initReaderEventRestPojo(ReaderEvent event) {
ReaderEventRestPojo ret = new ReaderEventRestPojo();
if (event != null && event.getPrintedCard() != null) {
if ( event.getPrintedCard() != null) {
if (event.getPrintedCard().getUser() != null) {
ret.setEventUser(PojoUtils.initEventUserRestPojo(event.getPrintedCard().getUser()));
}
} else if (event != null && event.getUser() != null) {
} else if (event.getUser() != null) {
ret.setEventUser(PojoUtils.initEventUserRestPojo(event.getUser()));
}
......@@ -168,10 +168,10 @@ public class PojoUtils {
ret.setReaderEventTime(event.getUpdatetime());
ret.setReaderId(event.getReader().getId());
if (event != null && event.getPrintedCard() != null) {
if (event.getPrintedCard() != null) {
ret.setPrintedCardId(event.getPrintedCard().getId());
}
if (event != null && event.getPrintedCard() != null) {
if (event.getPrintedCard() != null) {
ret.setPrintedCardState(event.getPrintedCard().getCardState().name());
}
return ret;
......
......@@ -112,7 +112,7 @@ public abstract class GenericImageServlet extends HttpServlet {
} else {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
response.getWriter().append("Error " + data.getResponse() + " while fetching data");
response.getWriter().append("Error " + (data == null ? "null-data" : data.getResponse()) + " while fetching data");
} else {
response.setContentLength(data.getData().length);
if (request.getParameter("download") != null)
......
......@@ -22,6 +22,7 @@ import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.Base64;
import java.util.Map;
......@@ -81,7 +82,7 @@ public class ErrorPageView implements Serializable {
Map<?, ?> requestMap = context.getExternalContext().getRequestMap();
Throwable ex = (Throwable) requestMap.get("javax.servlet.error.exception");
CRC32 stackHash = new CRC32();
stackHash.update(Arrays.toString(ex.getStackTrace()).getBytes());
stackHash.update(Arrays.toString(ex.getStackTrace()).getBytes(Charset.forName("UTF-8")));
return "0x" + Long.toHexString(stackHash.getValue());
......
......@@ -94,6 +94,10 @@ public class ImportView extends GenericCDIView {
}
}
if (bytes == null) {
return null;
}
String content = new String(bytes, UTF8);
String[] splittedIds = content.split(";");
for (String idstr : splittedIds) {
......
......@@ -99,7 +99,7 @@ public class UserCartView extends GenericCDIView {
sb.append("Added to event").append(CSV_SEPARATOR);
LanEvent event = null;
if (usercart != null && !usercart.isEmpty()) {
if (!usercart.isEmpty()) {
event = usercart.get(0).getEvent();
}
sb.append("\n");
......@@ -132,12 +132,12 @@ public class UserCartView extends GenericCDIView {
if (uc.getCreated() != null) {
ul.append(createtimeFormat.format(uc.getCreated().getTime()));
}
ul.append(CSV_SEPARATOR);
if (uc.getEventuserCreated() != null) {
ul.append(createtimeFormat.format(uc.getEventuserCreated()));
}
ul.append(CSV_SEPARATOR);
sb.append(ul.toString()
......@@ -146,9 +146,6 @@ public class UserCartView extends GenericCDIView {
.replaceAll(" ", " ")
);
sb.append("\n");
}
DefaultStreamedContent ret = new DefaultStreamedContent(new ByteArrayInputStream(sb.toString().getBytes(UTF8)));
......
......@@ -36,7 +36,7 @@ import javax.inject.Named;
@Named
@ConversationScoped
public class flowShopView extends GenericCDIView {
public class FlowShopView extends GenericCDIView {
private static final long serialVersionUID = 802344850073689859L;
......
......@@ -47,13 +47,9 @@ public class ProductShopItem implements Serializable {
private Map<ProductOptionGroup, ProductOption> selectedOptions = new HashMap<>();
private BigDecimal overriddenUnitPrice = BigDecimal.ZERO;
private boolean overrideUnitPrice = false;
public BigDecimal getCreditPrice()
{
if (BigDecimal.ZERO.compareTo(price) < 0)
......@@ -300,19 +296,19 @@ public class ProductShopItem implements Serializable {
public String getSelectedProductOptionString() {
String retString = "";
StringBuilder retString = new StringBuilder();
for(ProductOption option : this.selectedOptions.values()) {
if(option == null)
continue;
if(!retString.isEmpty()) {
retString += ", ";
if(retString.length() == 0) {
retString.append(", ");
}
retString += option.getName();
retString.append(option.getName());
}
return retString;
return retString.toString();
}
......
......@@ -60,11 +60,11 @@ public class UserOverviewItem {
this.rejectionMsgBody = mailBody;
else
this.rejectionMsgBody = "";
if(this.rejectionMsgSubject.contains("{0}") && eventUser != null && eventUser.getEvent() != null)
if(this.rejectionMsgSubject.contains("{0}") && eventUser.getEvent() != null)
this.rejectionMsgSubject = this.rejectionMsgSubject.replace("{0}", eventUser.getEvent().getName());
if(this.rejectionMsgBody.contains("{0}") && eventUser != null && eventUser.getEvent() != null)
if(this.rejectionMsgBody.contains("{0}") && eventUser.getEvent() != null)
this.rejectionMsgBody = this.rejectionMsgBody.replace("{0}", eventUser.getEvent().getName());
this.rejectionMsgToAddr = eventUser.getEmail();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!