You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by or...@apache.org on 2015/09/08 14:28:20 UTC
svn commit: r1701785 - in /qpid/java/trunk:
broker-core/src/test/java/org/apache/qpid/server/model/adapter/
common/src/main/java/org/apache/qpid/bytebuffer/
common/src/test/java/org/apache/qpid/bytebuffer/
Author: orudyy
Date: Tue Sep 8 12:28:20 2015
New Revision: 1701785
URL: http://svn.apache.org/r1701785
Log:
QPID-6727: [Java Broker] throw exception if initialising the QpidByteBuffer pool twice.
work by Lorenz Quack <qu...@gmail.com> and Alex Rudyy <or...@apache.org>
Modified:
qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/adapter/BrokerAdapterTest.java
qpid/java/trunk/common/src/main/java/org/apache/qpid/bytebuffer/QpidByteBuffer.java
qpid/java/trunk/common/src/test/java/org/apache/qpid/bytebuffer/QpidByteBufferTest.java
Modified: qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/adapter/BrokerAdapterTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/adapter/BrokerAdapterTest.java?rev=1701785&r1=1701784&r2=1701785&view=diff
==============================================================================
--- qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/adapter/BrokerAdapterTest.java (original)
+++ qpid/java/trunk/broker-core/src/test/java/org/apache/qpid/server/model/adapter/BrokerAdapterTest.java Tue Sep 8 12:28:20 2015
@@ -107,18 +107,12 @@ public class BrokerAdapterTest extends Q
attributes.put(Broker.NAME, "Broker");
attributes.put(Broker.MODEL_VERSION, BrokerModel.MODEL_VERSION);
attributes.put(Broker.DURABLE, true);
- attributes.put(Broker.CONTEXT, Collections.singletonMap(Broker.NETWORK_BUFFER_SIZE, Broker.MINIMUM_NETWORK_BUFFER_SIZE + 1));
- // testing successful case
- BrokerAdapter brokerAdapter = new BrokerAdapter(attributes, _systemConfig);
- brokerAdapter.open();
- assertEquals("Broker open should be successful", State.ACTIVE, brokerAdapter.getState());
- assertEquals("Unexpected buffer size", Broker.MINIMUM_NETWORK_BUFFER_SIZE + 1, brokerAdapter.getNetworkBufferSize());
- brokerAdapter.close();
+ // testing successful case is not possible because of the static nature of QpidByteBuffer which *should* be unrelated
// testing unsuccessful case
attributes.put(Broker.CONTEXT, Collections.singletonMap(Broker.NETWORK_BUFFER_SIZE, Broker.MINIMUM_NETWORK_BUFFER_SIZE - 1));
- brokerAdapter = new BrokerAdapter(attributes, _systemConfig);
+ BrokerAdapter brokerAdapter = new BrokerAdapter(attributes, _systemConfig);
brokerAdapter.open();
assertEquals("Broker open should fail with network buffer size less then minimum", State.ERRORED, brokerAdapter.getState());
assertEquals("Unexpected buffer size", Broker.DEFAULT_NETWORK_BUFFER_SIZE, brokerAdapter.getNetworkBufferSize());
Modified: qpid/java/trunk/common/src/main/java/org/apache/qpid/bytebuffer/QpidByteBuffer.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/main/java/org/apache/qpid/bytebuffer/QpidByteBuffer.java?rev=1701785&r1=1701784&r2=1701785&view=diff
==============================================================================
--- qpid/java/trunk/common/src/main/java/org/apache/qpid/bytebuffer/QpidByteBuffer.java (original)
+++ qpid/java/trunk/common/src/main/java/org/apache/qpid/bytebuffer/QpidByteBuffer.java Tue Sep 8 12:28:20 2015
@@ -597,12 +597,12 @@ public final class QpidByteBuffer
public synchronized static void initialisePool(int bufferSize, int maxPoolSize)
{
- if (_isPoolInitialized)
+ if (_isPoolInitialized && (bufferSize != _pooledBufferSize || maxPoolSize != _bufferPool.getMaxSize()))
{
- LOGGER.warn("QpidBteBuffer pool has already been initialised with bufferSize={} and maxPoolSize={}." +
- "Second initialisation with bufferSize={} and maxPoolSize={} will be ignored.",
- new Object[]{_pooledBufferSize, _bufferPool.getMaxSize(), bufferSize, maxPoolSize});
- return;
+ final String errorMessage = String.format("QpidBteBuffer pool has already been initialised with bufferSize=%d and maxPoolSize=%d." +
+ "Second initialisation with bufferSize=%d and maxPoolSize=%d will be ignored.",
+ _pooledBufferSize, _bufferPool.getMaxSize(), bufferSize, maxPoolSize);
+ throw new IllegalStateException(errorMessage);
}
_bufferPool = new BufferPool(maxPoolSize);
Modified: qpid/java/trunk/common/src/test/java/org/apache/qpid/bytebuffer/QpidByteBufferTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/common/src/test/java/org/apache/qpid/bytebuffer/QpidByteBufferTest.java?rev=1701785&r1=1701784&r2=1701785&view=diff
==============================================================================
--- qpid/java/trunk/common/src/test/java/org/apache/qpid/bytebuffer/QpidByteBufferTest.java (original)
+++ qpid/java/trunk/common/src/test/java/org/apache/qpid/bytebuffer/QpidByteBufferTest.java Tue Sep 8 12:28:20 2015
@@ -25,8 +25,8 @@ import org.apache.qpid.test.utils.QpidTe
public class QpidByteBufferTest extends QpidTestCase
{
- public static final int BUFFER_SIZE = 37;
- public static final int POOL_SIZE = 1;
+ public static final int BUFFER_SIZE = 1;
+ public static final int POOL_SIZE = 1 ;
@Override
protected void setUp() throws Exception
@@ -85,5 +85,18 @@ public class QpidByteBufferTest extends
{
// pass
}
+ }
+
+ public void testSettingUpPoolTwice() throws Exception
+ {
+ try
+ {
+ QpidByteBuffer.initialisePool(BUFFER_SIZE + 1, POOL_SIZE + 1);
+ fail("It is not legal to initialize buffer twice with different settings.");
+ }
+ catch (IllegalStateException e)
+ {
+ // pass
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org