From: John Napiorkowski Date: Wed, 19 Nov 2014 00:26:55 +0000 (-0600) Subject: make the env in Engine weak so that its request scoped X-Git-Tag: 5.90077^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=ee2c12fdbfa4662604cf07fa488b5c43c1e25b80 make the env in Engine weak so that its request scoped --- diff --git a/Changes b/Changes index 2d6fb80..28e8d58 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,12 @@ # This file documents the revision history for Perl extension Catalyst. +5.90077 - 2014-11-18 + - We store the PSGI $env in Catalyst::Engine for backcompat reasons. Changed + this so that the storage is a weak reference, so that it goes out of scope + with the request. This solves an issue where items in the stash (now in the + PSGI env) would not get closed at the end of the request. This caused some + regression, primarily in custom testing classes. + 5.90076 - 2014-11-13 - If throwing an exception object that does the code method, make sure that method returns an expected HTTP status code before passing it on to the diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index 8d8000b..e0b1117 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -127,7 +127,7 @@ __PACKAGE__->stats_class('Catalyst::Stats'); __PACKAGE__->_encode_check(Encode::FB_CROAK | Encode::LEAVE_SRC); # Remember to update this in Catalyst::Runtime as well! -our $VERSION = '5.90076'; +our $VERSION = '5.90077'; sub import { my ( $class, @arguments ) = @_; diff --git a/lib/Catalyst/Engine.pm b/lib/Catalyst/Engine.pm index 927d363..225a09a 100644 --- a/lib/Catalyst/Engine.pm +++ b/lib/Catalyst/Engine.pm @@ -23,7 +23,7 @@ use namespace::clean -except => 'meta'; our $CHUNKSIZE = 64 * 1024; # XXX - this is only here for compat, do not use! -has env => ( is => 'rw', writer => '_set_env' ); +has env => ( is => 'rw', writer => '_set_env' , weak_ref=>1); my $WARN_ABOUT_ENV = 0; around env => sub { my ($orig, $self, @args) = @_; diff --git a/lib/Catalyst/Runtime.pm b/lib/Catalyst/Runtime.pm index cbf5f7c..94d0f0b 100644 --- a/lib/Catalyst/Runtime.pm +++ b/lib/Catalyst/Runtime.pm @@ -7,7 +7,7 @@ BEGIN { require 5.008003; } # Remember to update this in Catalyst as well! -our $VERSION = '5.90076'; +our $VERSION = '5.90077'; =head1 NAME diff --git a/t/live_component_controller_context_closure.t b/t/live_component_controller_context_closure.t index fc0d622..72ddb15 100644 --- a/t/live_component_controller_context_closure.t +++ b/t/live_component_controller_context_closure.t @@ -22,7 +22,9 @@ use Catalyst::Test 'TestApp'; ok($resp->is_success); #is($ctx->count_leaks, 1); # FIXME: find out why this changed from 1 to 2 after 52af51596d - is($ctx->count_leaks, 2); + # ^^ probably has something to do with env being in Engine and Request - JNAP + # ^^ I made the env in Engine a weak ref, should help until we can remove it + is($ctx->count_leaks, 1); } {