Commit c5f5efb12c3c11cdd08761a7c86069701efba0e9

Authored by Arthur Nogueira Neves
2 parents 2932cb6f 28f27a92
Exists in master and in 1 other branch production

Merge pull request #797 from felixbuenemann/fix-gtalk-keepalive-thread-leak

Fix GtalkService Keeaplive-Thread leak
app/models/notification_services/gtalk_service.rb
... ... @@ -53,6 +53,8 @@ class NotificationServices::GtalkService < NotificationService
53 53 # post the issue to the xmpp room(s)
54 54 send_to_users(client, message) unless user_id.blank?
55 55 send_to_muc(client, message) unless room_id.blank?
  56 + ensure
  57 + client.close unless client.nil?
56 58 end
57 59  
58 60 private
... ...
spec/models/notification_service/gtalk_service_spec.rb
... ... @@ -28,6 +28,7 @@ describe NotificationService::GtalkService do
28 28  
29 29 #assert
30 30 expect(gtalk).to receive(:send).exactly(2).times.with(message)
  31 + expect(gtalk).to receive(:close)
31 32  
32 33 notification_service.create_notification(problem)
33 34 end
... ... @@ -57,6 +58,7 @@ describe NotificationService::GtalkService do
57 58 expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg)
58 59 expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new)
59 60 expect(@gtalk).to receive(:send).exactly(4).times
  61 + expect(@gtalk).to receive(:close)
60 62  
61 63 @notification_service.user_id = "first@domain.org,second@domain.org, third@domain.org , fourth@domain.org "
62 64 @notification_service.room_id = ""
... ... @@ -69,6 +71,7 @@ describe NotificationService::GtalkService do
69 71 expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg)
70 72 expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new)
71 73 expect(@gtalk).to receive(:send).exactly(4).times
  74 + expect(@gtalk).to receive(:close)
72 75  
73 76 @notification_service.user_id = "first@domain.org;second@domain.org; third@domain.org ; fourth@domain.org "
74 77 @notification_service.room_id = ""
... ... @@ -81,6 +84,7 @@ describe NotificationService::GtalkService do
81 84 expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg)
82 85 expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new)
83 86 expect(@gtalk).to receive(:send).exactly(4).times
  87 + expect(@gtalk).to receive(:close)
84 88  
85 89 @notification_service.user_id = "first@domain.org second@domain.org third@domain.org fourth@domain.org "
86 90 @notification_service.room_id = ""
... ... @@ -117,6 +121,7 @@ describe NotificationService::GtalkService do
117 121  
118 122 #assert
119 123 expect(gtalk).to receive(:send).with(message)
  124 + expect(gtalk).to receive(:close)
120 125  
121 126 notification_service.create_notification(problem)
122 127 end
... ...