File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ def address_match?(host, port)
1919
2020 # @return [String]
2121 def to_s
22- "#{ connection } (node_id=#{ @node_id . inspect } )"
22+ "#{ connection_to_s } (node_id=#{ @node_id . inspect } )"
2323 end
2424
2525 # @return [nil]
@@ -163,5 +163,9 @@ def send_request(request)
163163 def connection
164164 @connection ||= @connection_builder . build_connection ( @host , @port )
165165 end
166+
167+ def connection_to_s
168+ connection . to_s rescue nil
169+ end
166170 end
167171end
Original file line number Diff line number Diff line change @@ -132,4 +132,14 @@ def close
132132 broker . disconnect
133133 end
134134 end
135+
136+ describe "#to_s" do
137+ it "doesn't fail when building connection fails" do
138+ expect ( connection_builder ) . to receive ( :build_connection ) . and_raise ( Kafka ::ConnectionError )
139+
140+ expect do
141+ broker . to_s
142+ end . not_to raise_error
143+ end
144+ end
135145end
You can’t perform that action at this time.
0 commit comments