3030import java .util .concurrent .ExecutorService ;
3131import java .util .concurrent .TimeoutException ;
3232
33+ import com .rabbitmq .client .impl .AMQBasicProperties ;
3334import com .rabbitmq .client .test .TestUtils ;
3435import org .junit .Test ;
3536
@@ -104,9 +105,10 @@ public FrameMax() {
104105 closeChannel ();
105106 closeConnection ();
106107 ConnectionFactory cf = new GenerousConnectionFactory ();
108+ cf .setRequestedFrameMax (8192 );
107109 connection = cf .newConnection ();
108110 openChannel ();
109- basicPublishVolatile (new byte [connection .getFrameMax ()], "void" );
111+ basicPublishVolatile (new byte [connection .getFrameMax () * 2 ], "void" );
110112 expectError (AMQP .FRAME_ERROR );
111113 }
112114
@@ -123,7 +125,9 @@ public FrameMax() {
123125
124126 // create headers with zero-length value to calculate maximum header value size before exceeding frame_max
125127 headers .put (headerName , LongStringHelper .asLongString (new byte [0 ]));
126- AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ().headers (headers ).build ();
128+ AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ()
129+ .headers (headers )
130+ .build ();
127131 Frame minimalHeaderFrame = properties .toFrame (0 , 0 );
128132 int maxHeaderValueSize = FRAME_MAX - minimalHeaderFrame .size ();
129133
@@ -151,6 +155,33 @@ public FrameMax() {
151155 }
152156
153157
158+ // see rabbitmq/rabbitmq-java-client#407
159+ @ Test public void unlimitedFrameMaxWithHeaders ()
160+ throws IOException , TimeoutException {
161+ closeChannel ();
162+ closeConnection ();
163+ ConnectionFactory cf = newConnectionFactory ();
164+ cf .setRequestedFrameMax (0 );
165+ connection = cf .newConnection ();
166+ openChannel ();
167+
168+ Map <String , Object > headers = new HashMap <String , Object >();
169+ headers .put ("h1" , LongStringHelper .asLongString (new byte [250 ]));
170+ headers .put ("h1" , LongStringHelper .asLongString (new byte [500 ]));
171+ headers .put ("h1" , LongStringHelper .asLongString (new byte [750 ]));
172+ headers .put ("h1" , LongStringHelper .asLongString (new byte [5000 ]));
173+ headers .put ("h1" , LongStringHelper .asLongString (new byte [50000 ]));
174+ AMQP .BasicProperties properties = new AMQP .BasicProperties .Builder ()
175+ .headers (headers )
176+ .build ();
177+ basicPublishVolatile (new byte [500000 ], "" , "" , properties );
178+ }
179+
180+ @ Override
181+ protected boolean isAutomaticRecoveryEnabled () {
182+ return false ;
183+ }
184+
154185 /* ConnectionFactory that uses MyFrameHandler rather than
155186 * SocketFrameHandler. */
156187 private static class MyConnectionFactory extends ConnectionFactory {
0 commit comments