From 5afcc2594ac6a61ef93996b103997127bf43e04a Mon Sep 17 00:00:00 2001 From: Kieron Taylor <ktaylor@ebi.ac.uk> Date: Tue, 19 Apr 2016 15:42:16 +0100 Subject: [PATCH] [ENSCORESW-1664] Close up leaked internal cache in Gene object --- modules/Bio/EnsEMBL/Gene.pm | 3 ++- modules/t/gene.t | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/Bio/EnsEMBL/Gene.pm b/modules/Bio/EnsEMBL/Gene.pm index ff92da35b4..9f38bf8619 100755 --- a/modules/Bio/EnsEMBL/Gene.pm +++ b/modules/Bio/EnsEMBL/Gene.pm @@ -1013,7 +1013,8 @@ sub get_all_Transcripts { $self->{'_transcript_array'} = $transcripts; } } - return $self->{'_transcript_array'}; + my @array_copy = @{ $self->{'_transcript_array'} }; + return \@array_copy; } diff --git a/modules/t/gene.t b/modules/t/gene.t index 7ad82dc7ae..92909bdd3e 100644 --- a/modules/t/gene.t +++ b/modules/t/gene.t @@ -284,6 +284,13 @@ foreach my $tr (@{$gene->get_all_Transcripts()}) { ok($count == 5); ok($translates); +# Verify Transcript cache is not leaky +my $transcripts = $gene->get_all_Transcripts; +$count = @$transcripts; +pop @$transcripts; +$transcripts = $gene->get_all_Transcripts; +cmp_ok(scalar @$transcripts, '==', $count, "Gene's transcript cache is not modified by changing transcript lists in caller code"); + ok(scalar(@{$gene->get_all_Exons()}) == 3); $gene = $gene->transform("chromosome"); -- GitLab