Skip to content

Commit f4e6533

Browse files
fix uninitialized warning when removing an undef key in HTTP::Config (RT#105929)
1 parent 409b86f commit f4e6533

3 files changed

Lines changed: 18 additions & 1 deletion

File tree

Changes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Revision history for HTTP-Message
33

44
- converted all uses of Test.pm to Test::More
55

6+
- fix uninitialized warning in HTTP::Config (RT#105929)
7+
68

79
6.08 2015-07-10
810
- Resolve new uninitialized warning from

lib/HTTP/Config.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ sub find2 {
4040
ITEM:
4141
for my $item (@$self) {
4242
for my $k (keys %spec) {
43+
no warnings 'uninitialized';
4344
if (!exists $item->{$k} || $spec{$k} ne $item->{$k}) {
4445
push(@rest, $item);
4546
next ITEM;

t/http-config.t

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use strict;
22
use warnings;
33

44
use Test::More;
5-
plan tests => 14;
5+
plan tests => 16;
66

77
use HTTP::Config;
88

@@ -69,3 +69,17 @@ is(j($conf->matching_items($response)), "xhtml|html|any");
6969

7070
$response->content_type("text/html");
7171
is(j($conf->matching_items($response)), "HTML|html|text|any");
72+
73+
74+
{
75+
my @warnings;
76+
local $SIG{__WARN__} = sub { push @warnings, grep { length } @_ };
77+
78+
my $conf = HTTP::Config->new;
79+
$conf->add(owner => undef, callback => sub { 'bleah' });
80+
$conf->remove(owner => undef);
81+
82+
ok(($conf->empty), 'found and removed the config entry');
83+
is(scalar(@warnings), 0, 'no warnings')
84+
or diag('got warnings: ', explain(\@warnings));
85+
}

0 commit comments

Comments
 (0)