Remove Map null annotation workarounds (#8916)
These workarounds to prevent false positives can be removed now the EEAs allow for proper null analysis. Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -69,7 +69,7 @@ public class LifxLightDiscovery extends AbstractDiscoveryService {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(LifxLightDiscovery.class);
|
||||
|
||||
private final Map<MACAddress, @Nullable DiscoveredLight> discoveredLights = new HashMap<>();
|
||||
private final Map<MACAddress, DiscoveredLight> discoveredLights = new HashMap<>();
|
||||
private final long sourceId = randomSourceId();
|
||||
private final Supplier<Integer> sequenceNumberSupplier = new LifxSequenceNumberSupplier();
|
||||
|
||||
@@ -121,13 +121,13 @@ public class LifxLightDiscovery extends AbstractDiscoveryService {
|
||||
|
||||
@Activate
|
||||
@Override
|
||||
protected void activate(@Nullable Map<String, @Nullable Object> configProperties) {
|
||||
protected void activate(@Nullable Map<String, Object> configProperties) {
|
||||
super.activate(configProperties);
|
||||
}
|
||||
|
||||
@Modified
|
||||
@Override
|
||||
protected void modified(@Nullable Map<String, @Nullable Object> configProperties) {
|
||||
protected void modified(@Nullable Map<String, Object> configProperties) {
|
||||
super.modified(configProperties);
|
||||
}
|
||||
|
||||
@@ -248,9 +248,6 @@ public class LifxLightDiscovery extends AbstractDiscoveryService {
|
||||
// Iterate through the discovered lights that have to be set up, and the packets that have to be sent
|
||||
// Workaround to avoid a ConcurrentModifictionException on the selector.SelectedKeys() Set
|
||||
for (DiscoveredLight light : discoveredLights.values()) {
|
||||
if (light == null) {
|
||||
continue;
|
||||
}
|
||||
boolean waitingForLightResponse = System.currentTimeMillis() - light.lastRequestTimeMillis < 200;
|
||||
|
||||
if (light.supportedProduct && !light.isDataComplete() && !waitingForLightResponse) {
|
||||
|
||||
@@ -85,7 +85,7 @@ public class LifxLightStateChanger implements LifxLightStateListener {
|
||||
|
||||
private @Nullable ScheduledFuture<?> sendJob;
|
||||
|
||||
private Map<Integer, @Nullable List<PendingPacket>> pendingPacketsMap = new ConcurrentHashMap<>();
|
||||
private Map<Integer, List<PendingPacket>> pendingPacketsMap = new ConcurrentHashMap<>();
|
||||
|
||||
private class PendingPacket {
|
||||
|
||||
@@ -230,12 +230,10 @@ public class LifxLightStateChanger implements LifxLightStateListener {
|
||||
private @Nullable PendingPacket findPacketToSend() {
|
||||
PendingPacket result = null;
|
||||
for (List<PendingPacket> pendingPackets : pendingPacketsMap.values()) {
|
||||
if (pendingPackets != null) {
|
||||
for (PendingPacket pendingPacket : pendingPackets) {
|
||||
if (pendingPacket.hasAcknowledgeIntervalElapsed()
|
||||
&& (result == null || pendingPacket.lastSend < result.lastSend)) {
|
||||
result = pendingPacket;
|
||||
}
|
||||
for (PendingPacket pendingPacket : pendingPackets) {
|
||||
if (pendingPacket.hasAcknowledgeIntervalElapsed()
|
||||
&& (result == null || pendingPacket.lastSend < result.lastSend)) {
|
||||
result = pendingPacket;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -254,15 +252,13 @@ public class LifxLightStateChanger implements LifxLightStateListener {
|
||||
|
||||
private void removeFailedPackets() {
|
||||
for (List<PendingPacket> pendingPackets : pendingPacketsMap.values()) {
|
||||
if (pendingPackets != null) {
|
||||
Iterator<PendingPacket> it = pendingPackets.iterator();
|
||||
while (it.hasNext()) {
|
||||
PendingPacket pendingPacket = it.next();
|
||||
if (pendingPacket.sendCount > MAX_RETRIES && pendingPacket.hasAcknowledgeIntervalElapsed()) {
|
||||
logger.warn("{} failed (unacknowledged {} times to light {})",
|
||||
pendingPacket.packet.getClass().getSimpleName(), pendingPacket.sendCount, logId);
|
||||
it.remove();
|
||||
}
|
||||
Iterator<PendingPacket> it = pendingPackets.iterator();
|
||||
while (it.hasNext()) {
|
||||
PendingPacket pendingPacket = it.next();
|
||||
if (pendingPacket.sendCount > MAX_RETRIES && pendingPacket.hasAcknowledgeIntervalElapsed()) {
|
||||
logger.warn("{} failed (unacknowledged {} times to light {})",
|
||||
pendingPacket.packet.getClass().getSimpleName(), pendingPacket.sendCount, logId);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -270,14 +266,12 @@ public class LifxLightStateChanger implements LifxLightStateListener {
|
||||
|
||||
private @Nullable PendingPacket removeAcknowledgedPacket(int sequenceNumber) {
|
||||
for (List<PendingPacket> pendingPackets : pendingPacketsMap.values()) {
|
||||
if (pendingPackets != null) {
|
||||
Iterator<PendingPacket> it = pendingPackets.iterator();
|
||||
while (it.hasNext()) {
|
||||
PendingPacket pendingPacket = it.next();
|
||||
if (pendingPacket.packet.getSequence() == sequenceNumber) {
|
||||
it.remove();
|
||||
return pendingPacket;
|
||||
}
|
||||
Iterator<PendingPacket> it = pendingPackets.iterator();
|
||||
while (it.hasNext()) {
|
||||
PendingPacket pendingPacket = it.next();
|
||||
if (pendingPacket.packet.getSequence() == sequenceNumber) {
|
||||
it.remove();
|
||||
return pendingPacket;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public final class LifxThrottlingUtil {
|
||||
*/
|
||||
private static List<LifxLightCommunicationTracker> trackers = new CopyOnWriteArrayList<>();
|
||||
|
||||
private static Map<MACAddress, @Nullable LifxLightCommunicationTracker> macTrackerMapping = new ConcurrentHashMap<>();
|
||||
private static Map<MACAddress, LifxLightCommunicationTracker> macTrackerMapping = new ConcurrentHashMap<>();
|
||||
|
||||
public static void lock(@Nullable MACAddress mac) {
|
||||
if (mac != null) {
|
||||
|
||||
Reference in New Issue
Block a user