Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

HORNETQ-1147 - Client tries to use local-bind-address when using JMS connection factory from JNDI #948

Merged
merged 1 commit into from

2 participants

@jbertram
Owner

No description provided.

@andytaylor andytaylor merged commit b10c507 into hornetq:Branch_2_2_AS7

1 check passed

Details default Merged build finished.
@jbertram jbertram deleted the jbertram:Branch_2_2_AS7 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. @jbertram

    HORNETQ-1147 - Client tries to use local-bind-address when using JMS …

    jbertram authored
    …connection factory from JNDI
This page is out of date. Refresh to see the latest.
View
5 src/main/org/hornetq/api/core/DiscoveryGroupConfiguration.java
@@ -37,7 +37,7 @@
private String name;
- private String localBindAddress;
+ private transient String localBindAddress;
private String groupAddress;
@@ -161,8 +161,6 @@ public boolean equals(Object o)
if (groupPort != that.groupPort) return false;
if (refreshTimeout != that.refreshTimeout) return false;
if (groupAddress != null ? !groupAddress.equals(that.groupAddress) : that.groupAddress != null) return false;
- if (localBindAddress != null ? !localBindAddress.equals(that.localBindAddress) : that.localBindAddress != null)
- return false;
if (name != null ? !name.equals(that.name) : that.name != null) return false;
return true;
@@ -172,7 +170,6 @@ public boolean equals(Object o)
public int hashCode()
{
int result = name != null ? name.hashCode() : 0;
- result = 31 * result + (localBindAddress != null ? localBindAddress.hashCode() : 0);
result = 31 * result + (groupAddress != null ? groupAddress.hashCode() : 0);
result = 31 * result + groupPort;
result = 31 * result + (int) (refreshTimeout ^ (refreshTimeout >>> 32));
View
4 src/main/org/hornetq/core/config/BroadcastGroupConfiguration.java
@@ -34,9 +34,9 @@
private String name;
- private String localBindAddress;
+ private transient String localBindAddress;
- private int localBindPort;
+ private transient int localBindPort;
private String groupAddress;
View
116 .../src/org/hornetq/tests/integration/jms/connection/ConnectionFactorySerializationTest.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat licenses this file to you under the Apache License, version
+ * 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+package org.hornetq.tests.integration.jms.connection;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.Assert;
+import org.hornetq.api.core.DiscoveryGroupConfiguration;
+import org.hornetq.api.core.TransportConfiguration;
+import org.hornetq.api.jms.JMSFactoryType;
+import org.hornetq.core.config.BroadcastGroupConfiguration;
+import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
+import org.hornetq.jms.client.HornetQConnectionFactory;
+import org.hornetq.tests.util.JMSTestBase;
+
+/**
+ * @author Justin Bertram
+ */
+public class ConnectionFactorySerializationTest extends JMSTestBase
+{
+ // Constants -----------------------------------------------------
+
+ // Static --------------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+ protected static HornetQConnectionFactory cf;
+
+ // Constructors --------------------------------------------------
+ @Override
+ protected void setUp() throws Exception
+ {
+ try
+ {
+ super.setUp();
+ // Deploy a connection factory with discovery
+ List<String> bindings = new ArrayList<String>();
+ bindings.add("MyConnectionFactory");
+
+ DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration(getUDPDiscoveryAddress(), getUDPDiscoveryPort());
+
+ jmsServer.getHornetQServer().getConfiguration().getDiscoveryGroupConfigurations().put(dcConfig.getName(), dcConfig);
+
+ jmsServer.createConnectionFactory("MyConnectionFactory",
+ false,
+ JMSFactoryType.CF,
+ dcConfig.getName(),
+ "/MyConnectionFactory");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ // Public --------------------------------------------------------
+
+ public void testNullLocalBindAddress() throws Exception
+ {
+ cf = (HornetQConnectionFactory) context.lookup("/MyConnectionFactory");
+
+ // apparently looking up the connection factory with the org.hornetq.jms.tests.tools.container.InVMInitialContextFactory
+ // is not enough to actually serialize it so we serialize it manually
+ byte[] x = serialize(cf);
+ HornetQConnectionFactory y = deserialize(x, HornetQConnectionFactory.class);
+ Assert.assertEquals(null, y.getDiscoveryGroupConfiguration().getLocalBindAddress());
+ }
+
+ private static <T extends Serializable> byte[] serialize(T obj)
+ throws IOException
+ {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(obj);
+ oos.close();
+ return baos.toByteArray();
+ }
+
+ private static <T extends Serializable> T deserialize(byte[] b, Class<T> cl)
+ throws IOException, ClassNotFoundException
+ {
+ ByteArrayInputStream bais = new ByteArrayInputStream(b);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ Object o = ois.readObject();
+ return cl.cast(o);
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+}
Something went wrong with that request. Please try again.