Fix sonar findings on 21 style (#3020)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2026-04-15 16:57:10 +03:00
committed by GitHub
parent 643e96b7b1
commit 82ee1cc4e6
12 changed files with 284 additions and 273 deletions

View File

@@ -36,7 +36,7 @@ import org.springframework.transaction.TransactionSystemException;
@Slf4j
public class ExceptionMapper {
private static final Map<String, String> EXCEPTION_MAPPING = new HashMap<>(4);
private static final Map<String, String> EXCEPTION_MAPPING = HashMap.newHashMap(4);
// this is required to enable a certain order of exception and to select the most specific mappable exception according to the type
// hierarchy of the exception

View File

@@ -81,7 +81,7 @@ public class JpaConfiguration extends JpaBaseConfiguration {
@Override
protected Map<String, Object> getVendorProperties(final DataSource dataSource) {
final Map<String, Object> properties = new HashMap<>(7);
final Map<String, Object> properties = HashMap.newHashMap(7);
// Turn off dynamic weaving to disable LTW lookup in static weaving mode
properties.put(PersistenceUnitProperties.WEAVING, "false");
// needed for reports

View File

@@ -34,6 +34,7 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
/**
@@ -154,13 +155,13 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
return false;
}
final BaseEntity other = (BaseEntity) obj;
final Long id = getId();
final Long thisId = getId();
final Long otherId = other.getId();
if (id == null) {
if (thisId == null) {
if (otherId != null) {
return false;
}
} else if (!id.equals(otherId)) {
} else if (!thisId.equals(otherId)) {
return false;
}
return getOptLockRevision() == other.getOptLockRevision();
@@ -198,9 +199,9 @@ public abstract class AbstractJpaBaseEntity implements BaseEntity {
}
protected boolean isController() {
return SecurityContextHolder.getContext().getAuthentication() != null &&
SecurityContextHolder.getContext().getAuthentication().getDetails()
instanceof TenantAwareAuthenticationDetails tenantAwareDetails &&
tenantAwareDetails.controller();
final Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
return authentication != null
&& authentication.getDetails() instanceof TenantAwareAuthenticationDetails tenantAwareDetails
&& tenantAwareDetails.controller();
}
}

View File

@@ -678,7 +678,7 @@ public class JpaControllerManagement extends JpaActionManagement implements Cont
log.debug("{} events in flushUpdateQueue.", size);
final Set<TargetPoll> events = new HashSet<>(queue.size());
final Set<TargetPoll> events = HashSet.newHashSet(queue.size());
final int drained = queue.drainTo(events);
if (drained <= 0) {

View File

@@ -68,12 +68,12 @@ public class StatisticsUtils {
final Meter.Id id = m.getId();
if (id.getName().startsWith(Statistics.METER_PREFIX)) {
final double value;
if (m instanceof Counter counter) {
value = counter.count();
} else if (m instanceof FunctionCounter functionCounter) {
value = functionCounter.count();
} else {
return;
switch (m) {
case Counter counter -> value = counter.count();
case FunctionCounter functionCounter -> value = functionCounter.count();
default -> {
return;
}
}
final StringBuilder key = new StringBuilder(id.getName());