From f1c1e241b48997397616d9ac011647e2ac636397 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Wed, 22 Nov 2017 16:59:39 +0100 Subject: Fix Sonar warnings in FlatWriterRegistry Remove useless variables and simplify if conditions. Change-Id: I48a28334c47103057832f640c692c25625483bb6 Signed-off-by: Marek Gradzki --- .../translate/impl/write/registry/FlatWriterRegistry.java | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'infra/translate-impl') diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistry.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistry.java index d51ece23b..d8936850c 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistry.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/write/registry/FlatWriterRegistry.java @@ -194,8 +194,6 @@ final class FlatWriterRegistry implements WriterRegistry { checkAllTypesCanBeHandled(updates); LOG.debug("Performing bulk update for: {}", updates.keySet()); - DataObjectUpdate current = null; - // Iterate over all writers and call update if there are any related updates for (InstanceIdentifier writerType : writersOrder) { Collection writersData = updates.get(writerType); @@ -218,12 +216,11 @@ final class FlatWriterRegistry implements WriterRegistry { LOG.trace("Performing update with writer: {}", writer); for (DataObjectUpdate singleUpdate : writersData) { - current = singleUpdate; try { writer.processModification(singleUpdate.getId(), singleUpdate.getDataBefore(), singleUpdate.getDataAfter(), ctx); } catch (Exception e) { - throw new UpdateFailedException(e, alreadyProcessed, current); + throw new UpdateFailedException(e, alreadyProcessed, singleUpdate); } alreadyProcessed.add(singleUpdate); LOG.trace("Update successful for type: {}", writerType); @@ -238,13 +235,9 @@ final class FlatWriterRegistry implements WriterRegistry { List> noWriterNodes = new ArrayList<>(); for (InstanceIdentifier id : updates.keySet()) { // either there is direct writer for the iid - if (writersById.containsKey(id)) { - continue; - } else { - // or subtree one - if (writers.stream().anyMatch(o -> o.canProcess(id))) { + // or subtree one + if (writersById.containsKey(id) || writers.stream().anyMatch(o -> o.canProcess(id))) { continue; - } } noWriterNodes.add(id); } -- cgit 1.2.3-korg