Skip to content

Commit 34e6a7c

Browse files
committed
Merge pull request #3 from burak/master
Guard isa() checks with blessed().
2 parents aba0169 + 45a06bb commit 34e6a7c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dist.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ version = 0.014
1010
Thrift = 0
1111
Moo = 0
1212
Class::Accessor = 0
13+
Scalar::Util = 0
1314

1415
[PodWeaver]
1516

lib/Thrift/API/HiveClient2.pm

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use warnings;
77

88
use Moo;
99
use Carp;
10+
use Scalar::Util qw( blessed );
1011

1112
use Thrift;
1213
use Thrift::Socket;
@@ -131,7 +132,7 @@ has _session => (
131132
is => 'rwp',
132133
isa => sub {
133134
die "Session isn't a Thrift::API::HiveClient2::TOpenSessionResp"
134-
if !$_[0]->isa('Thrift::API::HiveClient2::TOpenSessionResp') },
135+
if ! blessed($_[0]) || !$_[0]->isa('Thrift::API::HiveClient2::TOpenSessionResp') },
135136
lazy => 1,
136137
builder => '_build_session',
137138
);
@@ -164,7 +165,7 @@ has _session_handle => (
164165
is => 'rwp',
165166
isa => sub {
166167
die "Session handle isn't a Thrift::API::HiveClient2::TSessionHandle"
167-
if !$_[0]->isa('Thrift::API::HiveClient2::TSessionHandle') },
168+
if ! blessed($_[0]) || !$_[0]->isa('Thrift::API::HiveClient2::TSessionHandle') },
168169
lazy => 1,
169170
builder => '_build_session_handle',
170171
);
@@ -178,7 +179,7 @@ has _operation => (
178179
is => "rwp",
179180
isa => sub {
180181
die "Operation isn't a Thrift::API::HiveClient2::TExecuteStatementResp"
181-
if defined $_[0] && !$_[0]->isa('Thrift::API::HiveClient2::TExecuteStatementResp') },
182+
if defined $_[0] && ( ! blessed($_[0]) || !$_[0]->isa('Thrift::API::HiveClient2::TExecuteStatementResp') ) },
182183
lazy => 1,
183184
);
184185

@@ -187,7 +188,7 @@ has _operation_handle => (
187188
isa => sub {
188189
die
189190
"Operation handle isn't a Thrift::API::HiveClient2::TOperationHandle"
190-
if defined $_[0] && !$_[0]->isa('Thrift::API::HiveClient2::TOperationHandle');
191+
if defined $_[0] && ( ! blessed($_[0]) || !$_[0]->isa('Thrift::API::HiveClient2::TOperationHandle') );
191192
},
192193
lazy => 1,
193194
);

0 commit comments

Comments
 (0)