Subject: | please correct use of UNIVERSAL::isa |
In Net::STOMP::Client::IO, you're using UNIVERSAL like this:
unless ($socket and UNIVERSAL::isa($socket, "IO::Socket")) {
The old documentation for UNIVERSAL encouraged that idiom, but the current documentation
highly discourages it (see http://perldoc.perl.org/UNIVERSAL.html under "but never do this!")
because it means overridden methods will never work.
The currently promoted idiom would be
unless ($socket and $socket->isa("IO::Socket")) {
I ran into this problem because I'm trying to use Test::MockObject to mock a Stomp
connection for testing, but I can't mock IO::Socket with the current code.
A patch is attached. Thanks!
Subject: | net-stomp-client-io.patch |
diff -Naur Net-STOMP-Client-1.2/lib/Net/STOMP/Client/IO.pm Net-STOMP-Client-patched/lib/Net/STOMP/Client/IO.pm
--- Net-STOMP-Client-1.2/lib/Net/STOMP/Client/IO.pm 2011-09-27 07:46:51.000000000 +0200
+++ Net-STOMP-Client-patched/lib/Net/STOMP/Client/IO.pm 2011-10-07 15:55:36.000000000 +0200
@@ -32,7 +32,6 @@
use Net::STOMP::Client::Error;
use IO::Select;
use Time::HiRes qw();
-use UNIVERSAL qw();
#
# constants
@@ -48,7 +47,7 @@
my($class, $socket) = @_;
my($self, $select);
- unless ($socket and UNIVERSAL::isa($socket, "IO::Socket")) {
+ unless ($socket and $socket->isa("IO::Socket")) {
Net::STOMP::Client::Error::report("Net::STOMP::Client::IO->new(): missing socket");
return();
}