@@ -82,7 +82,7 @@ public void testRejectLargeFramesDuringConnectionNegotiation()
8282 fail ("Expected exception during connection negotiation" );
8383 } catch (IOException e ) {
8484 } finally {
85- Host .rabbitmqctl ("eval 'application:set_env(rabbit, frame_max, 131768 ).'" );
85+ Host .rabbitmqctl ("eval 'application:set_env(rabbit, frame_max, 131072 ).'" );
8686 }
8787 }
8888
@@ -93,14 +93,17 @@ public void testRejectExceedingFrameMax()
9393 {
9494 closeChannel ();
9595 closeConnection ();
96- ConnectionFactory cf = new GenerousConnectionFactory ();
96+ Host .rabbitmqctl ("eval 'application:set_env(rabbit, frame_max, 4096).'" );
97+ ConnectionFactory cf = new ConnectionFactory ();
9798 connection = cf .newConnection ();
9899 openChannel ();
99100 try {
100- basicPublishVolatile (new byte [connection . getFrameMax () ], "void" );
101+ basicPublishVolatile (new byte [8196 ], "void" );
101102 channel .basicQos (0 );
102103 fail ("Expected exception when publishing" );
103104 } catch (IOException e ) {
105+ } finally {
106+ Host .rabbitmqctl ("eval 'application:set_env(rabbit, frame_max, 131072).'" );
104107 }
105108 }
106109
@@ -132,55 +135,4 @@ public Frame readFrame() throws IOException {
132135 return f ;
133136 }
134137 }
135-
136- /*
137- AMQConnection with a frame_max that is one higher than what it
138- tells the server.
139- */
140- private static class GenerousAMQConnection extends AMQConnection {
141-
142- public GenerousAMQConnection (ConnectionFactory factory ,
143- FrameHandler handler ,
144- ExecutorService executor ) {
145- super (factory .getUsername (),
146- factory .getPassword (),
147- handler ,
148- executor ,
149- factory .getVirtualHost (),
150- factory .getClientProperties (),
151- factory .getRequestedFrameMax (),
152- factory .getRequestedChannelMax (),
153- factory .getRequestedHeartbeat (),
154- factory .getSaslConfig ());
155- }
156-
157- @ Override public int getFrameMax () {
158- // the RabbitMQ broker permits frames that are oversize by
159- // up to EMPTY_FRAME_SIZE octets
160- return super .getFrameMax () + AMQCommand .EMPTY_FRAME_SIZE + 1 ;
161- }
162-
163- }
164-
165- private static class GenerousConnectionFactory extends ConnectionFactory {
166-
167- @ Override public Connection newConnection (ExecutorService executor , Address [] addrs )
168- throws IOException
169- {
170- IOException lastException = null ;
171- for (Address addr : addrs ) {
172- try {
173- FrameHandler frameHandler = createFrameHandler (addr );
174- AMQConnection conn = new GenerousAMQConnection (this , frameHandler , executor );
175- conn .start ();
176- return conn ;
177- } catch (IOException e ) {
178- lastException = e ;
179- }
180- }
181- throw (lastException != null ) ? lastException
182- : new IOException ("failed to connect" );
183- }
184- }
185-
186138}
0 commit comments