File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,6 +92,11 @@ public function isConnected(): bool
9292
9393 public function disconnect (): void
9494 {
95+ if (!$ this ->originConnection ) {
96+ // Already disconnected.
97+ return ;
98+ }
99+
95100 $ this ->getOriginConnection ()->disconnect ();
96101 $ this ->notify ();
97102
Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ private function flushMessages(MutableReceivedMessages $messages): void
114114 }
115115 }
116116
117+ $ messages ->clear ();
118+
117119 $ this ->getQueue ()->getChannel ()->getConnection ()->disconnect ();
118120
119121 throw $ e ;
Original file line number Diff line number Diff line change @@ -40,6 +40,26 @@ public function shouldSuccessConnect(): void
4040 $ this ->addToAssertionCount (1 );
4141 }
4242
43+ #[Test]
44+ public function shouldSuccessDisconnectTwice (): void
45+ {
46+ $ connection = $ this ->makeSpoolConnectionFactory ()->create ();
47+
48+ self ::assertFalse ($ connection ->isConnected ());
49+
50+ $ connection ->connect ();
51+
52+ self ::assertTrue ($ connection ->isConnected ());
53+
54+ $ connection ->disconnect ();
55+
56+ self ::assertFalse ($ connection ->isConnected ());
57+
58+ $ connection ->disconnect ();
59+
60+ self ::assertFalse ($ connection ->isConnected ());
61+ }
62+
4363 #[Test]
4464 public function shouldSuccessGetChannel (): void
4565 {
You can’t perform that action at this time.
0 commit comments