From d647ea4fdc4274507d0456c955f2dfbf66ae70c1 Mon Sep 17 00:00:00 2001 From: David Roazen Date: Fri, 1 Jul 2011 16:04:30 -0400 Subject: [PATCH] Long-delayed change to CachingIndexedFastaSequenceFile. Made the cache non-static to avoid problems when multiple references are used within the same thread (eg., during integration tests). This should kill the intermittent IndelRealignerIntegrationTest failures. --- .../utils/fasta/CachingIndexedFastaSequenceFile.java | 8 ++++---- .../fasta/CachingIndexedFastaSequenceFileUnitTest.java | 5 ----- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFile.java b/public/java/src/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFile.java index bda52dd4e..0c5085cc7 100644 --- a/public/java/src/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFile.java +++ b/public/java/src/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFile.java @@ -68,13 +68,13 @@ public class CachingIndexedFastaSequenceFile extends IndexedFastaSequenceFile { ReferenceSequence seq = null; } - private static ThreadLocal cache; + private ThreadLocal cache; - static { + { resetThreadLocalCache(); - }; + } - protected static void resetThreadLocalCache() { + protected void resetThreadLocalCache() { cache = new ThreadLocal () { @Override protected Cache initialValue() { return new Cache(); diff --git a/public/java/test/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFileUnitTest.java b/public/java/test/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFileUnitTest.java index a60f1b0fe..74cd8d8fe 100644 --- a/public/java/test/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFileUnitTest.java +++ b/public/java/test/org/broadinstitute/sting/utils/fasta/CachingIndexedFastaSequenceFileUnitTest.java @@ -34,11 +34,6 @@ public class CachingIndexedFastaSequenceFileUnitTest extends BaseTest { private static final List QUERY_SIZES = Arrays.asList(1, 10, 100, 1000); private static final List CACHE_SIZES = Arrays.asList(-1, 10, 1000); - @BeforeMethod - public void clearCache() { - CachingIndexedFastaSequenceFile.resetThreadLocalCache(); - } - @DataProvider(name = "fastas") public Object[][] createData1() { List params = new ArrayList();