diff --git a/src/main/java/htsjdk/variant/variantcontext/VariantContextBuilder.java b/src/main/java/htsjdk/variant/variantcontext/VariantContextBuilder.java index 57391c4c40..d7ce5f52e8 100644 --- a/src/main/java/htsjdk/variant/variantcontext/VariantContextBuilder.java +++ b/src/main/java/htsjdk/variant/variantcontext/VariantContextBuilder.java @@ -397,10 +397,13 @@ private void filtersAsIs(final Set filters) { /** * {@link #filters} * - * @param filters Set of strings to set as the filters for this builder + * @param filters Strings to set as the filters for this builder * @return this builder */ public VariantContextBuilder filters(final String ... filters) { + if(filters == null){ + this.unfiltered(); + } filtersAsIs(new LinkedHashSet<>(Arrays.asList(filters))); return this; } diff --git a/src/test/java/htsjdk/variant/variantcontext/VariantContextBuilderTest.java b/src/test/java/htsjdk/variant/variantcontext/VariantContextBuilderTest.java index 532039acc5..85cb25ac93 100644 --- a/src/test/java/htsjdk/variant/variantcontext/VariantContextBuilderTest.java +++ b/src/test/java/htsjdk/variant/variantcontext/VariantContextBuilderTest.java @@ -329,6 +329,19 @@ public void testCantCreateNullFilter(){ builder.filters((String)null); builder.make(); } - + + @Test + public void testNullFilterArray(){ + final VariantContextBuilder builder = new VariantContextBuilder("source", "contig", 1, 1, Arrays.asList(Tref, C, G)).filter("TEST"); + builder.filters((String[])null); + } + + @Test + public void testNullFilterSet(){ + final VariantContextBuilder builder = new VariantContextBuilder("source", "contig", 1, 1, Arrays.asList(Tref, C, G)).filter("TEST"); + builder.filters((Set)null); + builder.make(); + } + }