From 41c8a52cf088eab94b7d66ec608c8cad88e30d40 Mon Sep 17 00:00:00 2001 From: Alen Turkovic Date: Fri, 18 Sep 2020 18:59:34 +0200 Subject: [PATCH] Unmapped polymorphic elements will no longer be added to collections as nulls --- pom.xml | 2 +- .../com/github/alturkovic/asn/decoder/BerDecoder.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index bc8625a..0544ca3 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.github.alturkovic asn-parser - 1.4.1 + 1.4.2 asn-parser ASN.1 Decoding/Encoding diff --git a/src/main/java/com/github/alturkovic/asn/decoder/BerDecoder.java b/src/main/java/com/github/alturkovic/asn/decoder/BerDecoder.java index 6977914..acde70c 100644 --- a/src/main/java/com/github/alturkovic/asn/decoder/BerDecoder.java +++ b/src/main/java/com/github/alturkovic/asn/decoder/BerDecoder.java @@ -154,13 +154,13 @@ private void decodeCollection(final Collection collection, final byte[] if (taggedField.getType().isInterface()) { final var asnClassDescription = loadAsnClassDescription(taggedField.getType()); - collection.add(decodePolymorphic(asnClassDescription, elementBerData.toTlv())); + final var decodedType = decodePolymorphic(asnClassDescription, elementBerData.toTlv()); + if (decodedType != null) { + collection.add(decodedType); + } } else if (taggedField.getElementTag().equals(parsedElementTag)) { if (taggedField.isStructured()) { - final Object decoded = decodeStructure(taggedField.getType(), elementBerData.toTlv()); - if (decoded != null) { - collection.add(decoded); - } + collection.add(decodeStructure(taggedField.getType(), elementBerData.toTlv())); } else { //noinspection unchecked final var asnConverter = loadAsnConverterFromCache((Class>) taggedField.getConverter());