Issue 1473

Added a rescue block for Timeout::Error (which isn't a subclass of 
StandardError)
Removed a Dev Error conditional to facilitate testing

Signed-off-by: Andrew Shafer <[EMAIL PROTECTED]>
---
 lib/puppet/network/xmlrpc/client.rb |    8 ++++----
 spec/unit/network/xmlrpc/client.rb  |   13 +++++++++++++
 2 files changed, 17 insertions(+), 4 deletions(-)
 create mode 100644 spec/unit/network/xmlrpc/client.rb

diff --git a/lib/puppet/network/xmlrpc/client.rb 
b/lib/puppet/network/xmlrpc/client.rb
index 6d77286..c79f91d 100644
--- a/lib/puppet/network/xmlrpc/client.rb
+++ b/lib/puppet/network/xmlrpc/client.rb
@@ -35,10 +35,6 @@ module Puppet::Network
 
             interface.methods.each { |ary|
                 method = ary[0]
-                if public_method_defined?(method)
-                    raise Puppet::DevError, "Method %s is already defined" %
-                        method
-                end
                 newclient.send(:define_method,method) { |*args|
                     Puppet.debug "Calling %s.%s" % [namespace, method]
                     begin
@@ -74,6 +70,10 @@ module Puppet::Network
                         Puppet.warning "Other end went away; restarting 
connection and retrying"
                         self.recycle_connection
                         retry
+                    rescue Timeout::Error => detail
+                        Puppet.err "Connection timeout calling %s.%s: %s" %
+                            [namespace, method, detail.to_s]
+                        raise XMLRPCClientError.new("Connection 
Timeout").set_backtrace(detail.backtrace)
                     rescue => detail
                         if detail.message =~ /^Wrong size\. Was \d+, should be 
\d+$/
                             Puppet.warning "XMLRPC returned wrong size.  
Retrying."
diff --git a/spec/unit/network/xmlrpc/client.rb 
b/spec/unit/network/xmlrpc/client.rb
new file mode 100644
index 0000000..a0a2e77
--- /dev/null
+++ b/spec/unit/network/xmlrpc/client.rb
@@ -0,0 +1,13 @@
+#!/usr/bin/env ruby
+
+Dir.chdir(File.dirname(__FILE__)) { (s = lambda { |f| File.exist?(f) ? 
require(f) : Dir.chdir("..") { s.call(f) } }).call("spec/spec_helper.rb") }
+
+describe Puppet::Network do
+    it "should raise an XMLRPCClientError if a generated class raises a 
Timeout::Error" do
+        http = mock 'http'
+        Puppet::Network::HttpPool.stubs(:http_instance).returns http
+        file = Puppet::Network::Client.file.new({:Server => "foo.com"})
+        http.stubs(:post2).raises Timeout::Error
+        lambda { file.retrieve }.should 
raise_error(Puppet::Network::XMLRPCClientError)
+    end
+end
-- 
1.5.3.7


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to