From 6421f0dddf1ad963537f57c364198b19fcdea7c2 Mon Sep 17 00:00:00 2001 From: Jakub Morvay Date: Thu, 4 Jan 2018 12:14:13 +0100 Subject: Check for missing readers when building CompositeReaderRegistry Change-Id: Ic5e16e7a53836600236701caa51599bc0b957955 Signed-off-by: Jakub Morvay --- .../impl/read/registry/CompositeReaderRegistryBuilder.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java index 4f7e1e140..8ee84b40f 100644 --- a/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java +++ b/infra/translate-impl/src/main/java/io/fd/honeycomb/translate/impl/read/registry/CompositeReaderRegistryBuilder.java @@ -16,6 +16,7 @@ package io.fd.honeycomb.translate.impl.read.registry; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableMap; import io.fd.honeycomb.translate.impl.read.GenericListReader; import io.fd.honeycomb.translate.impl.read.GenericReader; @@ -131,8 +132,13 @@ public final class CompositeReaderRegistryBuilder } final ImmutableMap, Reader>> childReadersMap = childReadersMapB.build(); - return childReadersMap.isEmpty() - ? mappedReaders.get(instanceIdentifier) - : CompositeReader.createForReader(mappedReaders.get(instanceIdentifier), childReadersMap); + + if (childReadersMap.isEmpty()) { + return mappedReaders.get(instanceIdentifier); + } else { + final Reader reader = Preconditions.checkNotNull(mappedReaders.get(instanceIdentifier), + "Missing reader for %s", instanceIdentifier); + return CompositeReader.createForReader(reader, childReadersMap); + } } } -- cgit 1.2.3-korg