fix
This commit is contained in:
@@ -11,7 +11,7 @@ import java.math.BigDecimal;
|
||||
@Entity
|
||||
@Table(name = "transaction_item")
|
||||
@SuppressWarnings("common-java:DuplicatedBlocks")
|
||||
public class TransactionItem implements Serializable {
|
||||
public class TransactionItem implements Serializable, Comparable<TransactionItem> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -181,4 +181,9 @@ public class TransactionItem implements Serializable {
|
||||
", locked='" + getLocked() + "'" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(TransactionItem o) {
|
||||
return TransactionItemComparator.compare2(this, o);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,9 @@ import java.util.Comparator;
|
||||
|
||||
public class TransactionItemComparator implements Comparator<TransactionItem> {
|
||||
|
||||
private UserAccountComparator userAccountComparator = new UserAccountComparator();
|
||||
private static final UserAccountComparator userAccountComparator = new UserAccountComparator();
|
||||
|
||||
@Override
|
||||
public int compare(TransactionItem item1, TransactionItem item2) {
|
||||
public static int compare2(TransactionItem item1, TransactionItem item2) {
|
||||
// Sprawdzamy, czy którykolwiek z obiektów jest null
|
||||
if (item1 == null && item2 == null) return 0;
|
||||
if (item1 == null) return -1;
|
||||
@@ -17,7 +16,12 @@ public class TransactionItemComparator implements Comparator<TransactionItem> {
|
||||
return compareUserAccounts(item1.getUserAccount(), item2.getUserAccount());
|
||||
}
|
||||
|
||||
private int compareUserAccounts(UserAccount ua1, UserAccount ua2) {
|
||||
@Override
|
||||
public int compare(TransactionItem item1, TransactionItem item2) {
|
||||
return compare2(item1, item2);
|
||||
}
|
||||
|
||||
private static int compareUserAccounts(UserAccount ua1, UserAccount ua2) {
|
||||
// Używamy naszego komparatora UserAccount
|
||||
int compare = userAccountComparator.compare(ua1, ua2);
|
||||
if (compare == 0) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.sasiedzi.event.web.rest.errors;
|
||||
|
||||
import static org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation;
|
||||
|
||||
import com.sasiedzi.event.SasiedziApp;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.net.URI;
|
||||
import java.util.Arrays;
|
||||
@@ -9,7 +10,10 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.dao.ConcurrencyFailureException;
|
||||
@@ -57,9 +61,16 @@ public class ExceptionTranslator extends ResponseEntityExceptionHandler {
|
||||
this.env = env;
|
||||
}
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ExceptionTranslator.class);
|
||||
|
||||
@ExceptionHandler
|
||||
public ResponseEntity<Object> handleAnyException(Throwable ex, NativeWebRequest request) {
|
||||
ProblemDetailWithCause pdCause = wrapAndCustomizeProblem(ex, request);
|
||||
if (pdCause.getStatus() == HttpStatus.INTERNAL_SERVER_ERROR.value() && !env.matchesProfiles("dev")) {
|
||||
// If profile is dev, then Logging Aspect will handle logging.
|
||||
// In all other profiles no error is logged :-( No idea why that should be a good decision.
|
||||
LOG.error("Internal Server error happened", ex);
|
||||
}
|
||||
return handleExceptionInternal((Exception) ex, pdCause, buildHeaders(ex), HttpStatusCode.valueOf(pdCause.getStatus()), request);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user