From f0c54d99ed2e6b2feaaa0025f917c6783c21d6c1 Mon Sep 17 00:00:00 2001 From: Joel Thibault Date: Fri, 22 Jun 2012 16:56:04 -0400 Subject: [PATCH] Account for a null attributes object * field attributesCanBeModified - a null attributes object can't be modified in its current state * method makeAttributesModifiable() - initialize a null attributes object to empty --- .../utils/variantcontext/VariantContextBuilder.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextBuilder.java b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextBuilder.java index c6c2ac2c7..83ddd2a1f 100644 --- a/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextBuilder.java +++ b/public/java/src/org/broadinstitute/sting/utils/variantcontext/VariantContextBuilder.java @@ -182,7 +182,13 @@ public class VariantContextBuilder { * @param attributes */ public VariantContextBuilder attributes(final Map attributes) { - this.attributes = attributes; + if (attributes != null) { + this.attributes = attributes; + } + else { + this.attributes = new HashMap(); + } + this.attributesCanBeModified = true; return this; } @@ -220,6 +226,7 @@ public class VariantContextBuilder { * Makes the attributes field modifiable. In many cases attributes is just a pointer to an immutable * collection, so methods that want to add / remove records require the attributes to be copied to a */ + @Ensures({"this.attributesCanBeModified"}) private void makeAttributesModifiable() { if ( ! attributesCanBeModified ) { this.attributesCanBeModified = true;