This closes #106 fixes
This commit is contained in:
commit
bff0886b0c
|
@ -23,6 +23,8 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.net.URI;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedExceptionAction;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -50,6 +52,7 @@ import org.apache.activemq.artemis.core.server.JournalType;
|
|||
import org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
|
||||
import org.apache.activemq.artemis.utils.ObjectInputStreamWithClassLoader;
|
||||
|
||||
public class ConfigurationImpl implements Configuration, Serializable
|
||||
{
|
||||
|
@ -114,9 +117,9 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
|
||||
private List<CoreQueueConfiguration> queueConfigurations = new ArrayList<CoreQueueConfiguration>();
|
||||
|
||||
protected List<BroadcastGroupConfiguration> broadcastGroupConfigurations = new ArrayList<BroadcastGroupConfiguration>();
|
||||
protected transient List<BroadcastGroupConfiguration> broadcastGroupConfigurations = new ArrayList<BroadcastGroupConfiguration>();
|
||||
|
||||
protected Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = new LinkedHashMap<String, DiscoveryGroupConfiguration>();
|
||||
protected transient Map<String, DiscoveryGroupConfiguration> discoveryGroupConfigurations = new LinkedHashMap<String, DiscoveryGroupConfiguration>();
|
||||
|
||||
// Paging related attributes ------------------------------------------------------------
|
||||
|
||||
|
@ -1586,11 +1589,28 @@ public class ConfigurationImpl implements Configuration, Serializable
|
|||
@Override
|
||||
public Configuration copy() throws Exception
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream os = new ObjectOutputStream(bos);
|
||||
os.writeObject(this);
|
||||
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bos.toByteArray()));
|
||||
return (Configuration) ois.readObject();
|
||||
|
||||
return AccessController.doPrivileged(new PrivilegedExceptionAction<Configuration>()
|
||||
{
|
||||
@Override
|
||||
public Configuration run() throws Exception
|
||||
{
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream os = new ObjectOutputStream(bos);
|
||||
os.writeObject(ConfigurationImpl.this);
|
||||
ObjectInputStream ois = new ObjectInputStreamWithClassLoader(new ByteArrayInputStream(bos.toByteArray()));
|
||||
Configuration config = (Configuration) ois.readObject();
|
||||
|
||||
// this is transient because of possible jgroups integration, we need to copy it manually
|
||||
config.setBroadcastGroupConfigurations(ConfigurationImpl.this.getBroadcastGroupConfigurations());
|
||||
|
||||
// this is transient because of possible jgroups integration, we need to copy it manually
|
||||
config.setDiscoveryGroupConfigurations(ConfigurationImpl.this.getDiscoveryGroupConfigurations());
|
||||
|
||||
return config;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -22,17 +22,12 @@ import org.apache.activemq.artemis.core.config.Configuration;
|
|||
import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
|
||||
import org.apache.activemq.artemis.core.journal.impl.JournalConstants;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.tests.util.RandomUtil;
|
||||
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
|
||||
import org.apache.activemq.artemis.tests.util.RandomUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
public class ConfigurationImplTest extends ActiveMQTestBase
|
||||
{
|
||||
protected Configuration conf;
|
||||
|
@ -497,14 +492,9 @@ public class ConfigurationImplTest extends ActiveMQTestBase
|
|||
conf.setClusterPassword(s);
|
||||
Assert.assertEquals(s, conf.getClusterPassword());
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos = new ObjectOutputStream(baos);
|
||||
oos.writeObject(conf);
|
||||
oos.flush();
|
||||
// This will use serialization to perform a deep copy of the object
|
||||
Configuration conf2 = conf.copy();
|
||||
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
|
||||
ObjectInputStream ois = new ObjectInputStream(bais);
|
||||
Configuration conf2 = (Configuration)ois.readObject();
|
||||
|
||||
Assert.assertTrue(conf.equals(conf2));
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ public class ClosingConnectionTest extends ActiveMQTestBase
|
|||
@BMRule
|
||||
(
|
||||
name = "rule to kill connection",
|
||||
targetClass = "org.apache.activemq.artemis.core.journal.impl.NIOSequentialFile",
|
||||
targetClass = "org.apache.activemq.artemis.core.io.nio.NIOSequentialFile",
|
||||
targetMethod = "open(int, boolean)",
|
||||
targetLocation = "AT INVOKE java.nio.channels.FileChannel.size()",
|
||||
action = "org.apache.activemq.artemis.tests.extras.byteman.ClosingConnectionTest.killConnection();"
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.extras.byteman;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
|
||||
import org.apache.activemq.artemis.api.core.client.ClientMessage;
|
||||
|
@ -38,10 +42,6 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@RunWith(BMUnitRunner.class)
|
||||
public class PagingLeakTest extends ActiveMQTestBase
|
||||
{
|
||||
|
@ -122,7 +122,7 @@ public class PagingLeakTest extends ActiveMQTestBase
|
|||
// A backup that will be waiting to be activated
|
||||
Configuration config = createDefaultNettyConfig();
|
||||
|
||||
config.setJournalBufferTimeout_AIO(0).setJournalBufferTimeout_NIO(0);
|
||||
config.setJournalBufferTimeout_AIO(10).setJournalBufferTimeout_NIO(10);
|
||||
|
||||
final ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
|
||||
|
||||
|
|
|
@ -1345,7 +1345,7 @@ public class BridgeTest extends ActiveMQTestBase
|
|||
Map<String, Object> server1Params = new HashMap<String, Object>();
|
||||
addTargetParameters(server1Params);
|
||||
server1 = createClusteredServerWithParams(isNetty(), 1, true, PAGE_SIZE, PAGE_MAX, server1Params);
|
||||
server1.getConfiguration().setJournalBufferTimeout_AIO(0).setJournalBufferTimeout_NIO(0);
|
||||
server1.getConfiguration().setJournalBufferTimeout_AIO(10).setJournalBufferTimeout_NIO(10);
|
||||
|
||||
final String testAddress = "testAddress";
|
||||
final String queueName0 = "queue0";
|
||||
|
@ -1360,7 +1360,7 @@ public class BridgeTest extends ActiveMQTestBase
|
|||
|
||||
server0.getConfiguration().setConnectorConfigurations(connectors);
|
||||
|
||||
server0.getConfiguration().setIDCacheSize(20000).setJournalBufferTimeout_NIO(0).setJournalBufferTimeout_AIO(0);
|
||||
server0.getConfiguration().setIDCacheSize(20000).setJournalBufferTimeout_NIO(10).setJournalBufferTimeout_AIO(10);
|
||||
|
||||
ArrayList<String> staticConnectors = new ArrayList<String>();
|
||||
staticConnectors.add(server1tc.getName());
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.activemq.artemis.tests.integration.jms.connection;
|
||||
|
||||
import javax.jms.Queue;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
|
@ -23,19 +24,19 @@ import java.io.ObjectInputStream;
|
|||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.jms.Queue;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.BroadcastEndpoint;
|
||||
import org.apache.activemq.artemis.api.core.BroadcastEndpointFactory;
|
||||
import org.apache.activemq.artemis.api.core.ChannelBroadcastEndpointFactory;
|
||||
import org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration;
|
||||
import org.apache.activemq.artemis.api.core.JGroupsFileBroadcastEndpointFactory;
|
||||
import org.apache.activemq.artemis.api.jms.JMSFactoryType;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.artemis.tests.util.JMSTestBase;
|
||||
import org.jgroups.JChannel;
|
||||
import org.jgroups.conf.PlainConfigurator;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -168,6 +169,14 @@ public class ConnectionFactoryWithJGroupsSerializationTest extends JMSTestBase
|
|||
assertTrue(broadcastEndpoint instanceof JGroupsFileBroadcastEndpointFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCopyConfiguration() throws Exception
|
||||
{
|
||||
Assert.assertEquals(2, jmsServer.getActiveMQServer().getConfiguration().getDiscoveryGroupConfigurations().size());
|
||||
Configuration copiedconfig = jmsServer.getActiveMQServer().getConfiguration().copy();
|
||||
Assert.assertEquals(2, copiedconfig.getDiscoveryGroupConfigurations().size());
|
||||
}
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception
|
||||
|
|
Loading…
Reference in New Issue