make the env in Engine weak so that its request scoped 5.90077
John Napiorkowski [Wed, 19 Nov 2014 00:26:55 +0000 (18:26 -0600)]
Changes
lib/Catalyst.pm
lib/Catalyst/Engine.pm
lib/Catalyst/Runtime.pm
t/live_component_controller_context_closure.t

diff --git a/Changes b/Changes
index 2d6fb80..28e8d58 100644 (file)
--- 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
index 8d8000b..e0b1117 100644 (file)
@@ -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 ) = @_;
index 927d363..225a09a 100644 (file)
@@ -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) = @_;
index cbf5f7c..94d0f0b 100644 (file)
@@ -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
 
index fc0d622..72ddb15 100644 (file)
@@ -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);
 }
 
 {