From be30b3ccba38b91f3842a80e83bd483665030aa2 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Tue, 27 Jan 2015 19:47:49 +0000 Subject: QPID-6339 : Use variable interpolation for help url and initial virtual host config git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655138 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/common/QpidProperties.java | 26 +++++++++++++--------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java index cdd44d3443..74219f216e 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java @@ -20,14 +20,14 @@ */ package org.apache.qpid.common; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.io.IOException; import java.io.InputStream; import java.util.Map; import java.util.Properties; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * QpidProperties captures the project name, version number, and source code repository revision number from a properties * file which is generated as part of the build process. Normally, the name and version number are pulled from the module @@ -76,10 +76,11 @@ public class QpidProperties /** Holds the source code revision. */ private static String buildVersion = DEFAULT; + private static final Properties properties = new Properties(); + // Loads the values from the version properties file. static { - Properties props = new Properties(); try { @@ -90,12 +91,12 @@ public class QpidProperties } else { - props.load(propertyStream); + properties.load(propertyStream); if (_logger.isDebugEnabled()) { _logger.debug("Dumping QpidProperties"); - for (Map.Entry entry : props.entrySet()) + for (Map.Entry entry : properties.entrySet()) { _logger.debug("Property: " + entry.getKey() + " Value: " + entry.getValue()); } @@ -103,11 +104,11 @@ public class QpidProperties _logger.debug("End of property dump"); } - productName = readPropertyValue(props, PRODUCT_NAME_PROPERTY); - String versionSuffix = (String) props.get(RELEASE_VERSION_SUFFIX); - String version = readPropertyValue(props, RELEASE_VERSION_PROPERTY); + productName = readPropertyValue(properties, PRODUCT_NAME_PROPERTY); + String versionSuffix = (String) properties.get(RELEASE_VERSION_SUFFIX); + String version = readPropertyValue(properties, RELEASE_VERSION_PROPERTY); releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix; - buildVersion = readPropertyValue(props, BUILD_VERSION_PROPERTY); + buildVersion = readPropertyValue(properties, BUILD_VERSION_PROPERTY); } } catch (IOException e) @@ -117,6 +118,11 @@ public class QpidProperties } } + public static Properties asProperties() + { + return new Properties(properties); + } + /** * Gets the product name. * -- cgit v1.2.1 From d1b8f6e25ceaa628fd4f1c97847f5fb557032f7f Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Tue, 27 Jan 2015 20:14:14 +0000 Subject: QPID-6340 : Allow defaults for system properties to be overridden from a properties file git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655142 13f79535-47bb-0310-9956-ffa450edef68 --- .../qpid/configuration/ClientProperties.java | 55 ++++++++++++++++++++++ .../qpid/configuration/CommonProperties.java | 54 +++++++++++++++++++++ 2 files changed, 109 insertions(+) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java index 86f5ddeeed..89e4c3ccdd 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/ClientProperties.java @@ -18,6 +18,17 @@ package org.apache.qpid.configuration; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + /** * This class centralized the Qpid client properties. * @@ -25,6 +36,8 @@ package org.apache.qpid.configuration; */ public class ClientProperties { + private static final Logger LOGGER = LoggerFactory.getLogger(ClientProperties.class); + /** * Currently with Qpid it is not possible to change the client ID. * If one is not specified upon connection construction, an id is generated automatically. @@ -292,6 +305,48 @@ public class ClientProperties */ public static final String QPID_USE_LEGACY_GETQUEUEDEPTH_BEHAVIOUR = "qpid.use_legacy_getqueuedepth_behavior"; + static + { + // force load of common properties + Class commonPropertiesClass = CommonProperties.class; + + Properties props = new Properties(); + String initialProperties = System.getProperty("qpid.client_properties_file"); + URL initialPropertiesLocation = null; + try + { + if (initialProperties == null) + { + initialPropertiesLocation = ClientProperties.class.getClassLoader().getResource("qpid-client.properties"); + } + else + { + initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); + } + + if (initialPropertiesLocation != null) + { + props.load(initialPropertiesLocation.openStream()); + } + } + catch (MalformedURLException e) + { + LOGGER.warn("Could not open client properties file '"+initialProperties+"'.", e); + } + catch (IOException e) + { + LOGGER.warn("Could not open client properties file '" + initialPropertiesLocation + "'.", e); + } + + Set propertyNames = new HashSet<>(props.stringPropertyNames()); + propertyNames.removeAll(System.getProperties().stringPropertyNames()); + for (String propName : propertyNames) + { + System.setProperty(propName, props.getProperty(propName)); + } + + } + private ClientProperties() { //No instances diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java index 6bae93a1b8..a052a02748 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/CommonProperties.java @@ -20,6 +20,19 @@ */ package org.apache.qpid.configuration; +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashSet; +import java.util.Properties; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.apache.qpid.common.QpidProperties; + /** * Centralised record of Qpid common properties. * @@ -27,6 +40,8 @@ package org.apache.qpid.configuration; */ public class CommonProperties { + private static final Logger LOGGER = LoggerFactory.getLogger(CommonProperties.class); + /** * The timeout used by the IO layer for timeouts such as send timeout in IoSender, and the close timeout for IoSender and IoReceiver */ @@ -36,6 +51,45 @@ public class CommonProperties public static final String HANDSHAKE_TIMEOUT_PROP_NAME = "qpid.handshake_timeout"; public static final int HANDSHAKE_TIMEOUT_DEFAULT = 2; + static + { + + Properties props = new Properties(QpidProperties.asProperties()); + String initialProperties = System.getProperty("qpid.common_properties_file"); + URL initialPropertiesLocation = null; + try + { + if (initialProperties == null) + { + initialPropertiesLocation = CommonProperties.class.getClassLoader().getResource("qpid-common.properties"); + } + else + { + initialPropertiesLocation = (new File(initialProperties)).toURI().toURL(); + } + + if (initialPropertiesLocation != null) + { + props.load(initialPropertiesLocation.openStream()); + } + } + catch (MalformedURLException e) + { + LOGGER.warn("Could not open common properties file '"+initialProperties+"'.", e); + } + catch (IOException e) + { + LOGGER.warn("Could not open common properties file '" + initialPropertiesLocation + "'.", e); + } + + Set propertyNames = new HashSet<>(props.stringPropertyNames()); + propertyNames.removeAll(System.getProperties().stringPropertyNames()); + for (String propName : propertyNames) + { + System.setProperty(propName, props.getProperty(propName)); + } + + } private CommonProperties() { -- cgit v1.2.1 From 60089dfd1a12303822b3f82816905f0a29a6a746 Mon Sep 17 00:00:00 2001 From: Robert Godfrey Date: Tue, 27 Jan 2015 22:59:46 +0000 Subject: QPID-6342 : Fail fast when commands sent in wrong order git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655186 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/codec/ServerDecoder.java | 64 +++++++++++----------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java index 32a45da60c..deed32346f 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/codec/ServerDecoder.java @@ -42,7 +42,6 @@ public class ServerDecoder extends AMQDecoder methodProcessor = getMethodProcessor(); - ServerChannelMethodProcessor channelMethodProcessor = methodProcessor.getChannelMethodProcessor(channelId); final int classAndMethod = in.readInt(); int classId = classAndMethod >> 16; int methodId = classAndMethod & 0xFFFF; @@ -115,116 +114,117 @@ public class ServerDecoder extends AMQDecoder Date: Wed, 28 Jan 2015 20:34:16 +0000 Subject: QPID-6345 : Allow enabled cipher suites to be configured git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655457 13f79535-47bb-0310-9956-ffa450edef68 --- .../transport/NetworkTransportConfiguration.java | 11 ++- .../transport/network/io/IoNetworkTransport.java | 1 + .../transport/network/security/ssl/SSLUtil.java | 97 ++++++++++++++++++---- 3 files changed, 92 insertions(+), 17 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java index 12f8d801dc..7af3b7af39 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/NetworkTransportConfiguration.java @@ -21,6 +21,7 @@ package org.apache.qpid.transport; import java.net.InetSocketAddress; +import java.util.Collection; /** * This interface provides a means for NetworkDrivers to configure TCP options such as incoming and outgoing @@ -30,17 +31,21 @@ import java.net.InetSocketAddress; public interface NetworkTransportConfiguration { // Taken from Socket - Boolean getTcpNoDelay(); + boolean getTcpNoDelay(); // The amount of memory in bytes to allocate to the incoming buffer - Integer getReceiveBufferSize(); + int getReceiveBufferSize(); // The amount of memory in bytes to allocate to the outgoing buffer - Integer getSendBufferSize(); + int getSendBufferSize(); InetSocketAddress getAddress(); boolean needClientAuth(); boolean wantClientAuth(); + + Collection getEnabledCipherSuites(); + + Collection getDisabledCipherSuites(); } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java index e5bc9fa977..b7998ab8d9 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoNetworkTransport.java @@ -190,6 +190,7 @@ public class IoNetworkTransport implements OutgoingNetworkTransport, IncomingNet SSLServerSocket sslServerSocket = (SSLServerSocket) _serverSocket; SSLUtil.removeSSLv3Support(sslServerSocket); + SSLUtil.updateEnabledCipherSuites(sslServerSocket, config.getEnabledCipherSuites(), config.getDisabledCipherSuites()); if(config.needClientAuth()) { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java index b6ae2ab4a3..67dde84440 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLUtil.java @@ -24,6 +24,9 @@ import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.net.URL; import java.security.GeneralSecurityException; import java.security.KeyStore; @@ -33,7 +36,10 @@ import java.security.cert.CertificateParsingException; import java.security.cert.X509Certificate; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; @@ -266,7 +272,35 @@ public class SSLUtil return ks; } - public static void removeSSLv3Support(final SSLEngine engine) + private static interface SSLEntity + { + String[] getEnabledCipherSuites(); + + void setEnabledCipherSuites(String[] strings); + + String[] getEnabledProtocols(); + + void setEnabledProtocols(String[] protocols); + + String[] getSupportedCipherSuites(); + + String[] getSupportedProtocols(); + } + + private static SSLEntity asSSLEntity(final Object object, final Class clazz) + { + return (SSLEntity) Proxy.newProxyInstance(SSLEntity.class.getClassLoader(), new Class[] { SSLEntity.class }, new InvocationHandler() + { + @Override + public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable + { + Method delegateMethod = clazz.getMethod(method.getName(), method.getParameterTypes()); + return delegateMethod.invoke(object, args); + } + }) ; + } + + private static void removeSSLv3Support(final SSLEntity engine) { List enabledProtocols = Arrays.asList(engine.getEnabledProtocols()); if(enabledProtocols.contains(SSLV3_PROTOCOL)) @@ -277,26 +311,61 @@ public class SSLUtil } } - public static void removeSSLv3Support(final SSLSocket socket) + public static void removeSSLv3Support(final SSLEngine engine) { - List enabledProtocols = Arrays.asList(socket.getEnabledProtocols()); - if(enabledProtocols.contains(SSLV3_PROTOCOL)) - { - List allowedProtocols = new ArrayList<>(enabledProtocols); - allowedProtocols.remove(SSLV3_PROTOCOL); - socket.setEnabledProtocols(allowedProtocols.toArray(new String[allowedProtocols.size()])); - } + removeSSLv3Support(asSSLEntity(engine, SSLEngine.class)); } + public static void removeSSLv3Support(final SSLSocket socket) + { + removeSSLv3Support(asSSLEntity(socket, SSLSocket.class)); + } public static void removeSSLv3Support(final SSLServerSocket socket) { - List enabledProtocols = Arrays.asList(socket.getEnabledProtocols()); - if(enabledProtocols.contains(SSLV3_PROTOCOL)) + removeSSLv3Support(asSSLEntity(socket, SSLServerSocket.class)); + } + + private static void updateEnabledCipherSuites(final SSLEntity entity, + final Collection enabledCipherSuites, + final Collection disabledCipherSuites) + { + if(enabledCipherSuites != null && !enabledCipherSuites.isEmpty()) { - List allowedProtocols = new ArrayList<>(enabledProtocols); - allowedProtocols.remove(SSLV3_PROTOCOL); - socket.setEnabledProtocols(allowedProtocols.toArray(new String[allowedProtocols.size()])); + final Set supportedSuites = + new HashSet<>(Arrays.asList(entity.getSupportedCipherSuites())); + supportedSuites.retainAll(enabledCipherSuites); + entity.setEnabledCipherSuites(supportedSuites.toArray(new String[supportedSuites.size()])); + } + + if(disabledCipherSuites != null && !disabledCipherSuites.isEmpty()) + { + final Set enabledSuites = new HashSet<>(Arrays.asList(entity.getEnabledCipherSuites())); + enabledSuites.removeAll(disabledCipherSuites); + entity.setEnabledCipherSuites(enabledSuites.toArray(new String[enabledSuites.size()])); } + + } + + + public static void updateEnabledCipherSuites(final SSLEngine engine, + final Collection enabledCipherSuites, + final Collection disabledCipherSuites) + { + updateEnabledCipherSuites(asSSLEntity(engine, SSLEngine.class), enabledCipherSuites, disabledCipherSuites); + } + + public static void updateEnabledCipherSuites(final SSLServerSocket socket, + final Collection enabledCipherSuites, + final Collection disabledCipherSuites) + { + updateEnabledCipherSuites(asSSLEntity(socket, SSLServerSocket.class), enabledCipherSuites, disabledCipherSuites); + } + + public static void updateEnabledCipherSuites(final SSLSocket socket, + final Collection enabledCipherSuites, + final Collection disabledCipherSuites) + { + updateEnabledCipherSuites(asSSLEntity(socket, SSLSocket.class), enabledCipherSuites, disabledCipherSuites); } } -- cgit v1.2.1 From e860a568e040c2b6a1ebfd6035cc77fdc3933473 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Wed, 28 Jan 2015 22:13:26 +0000 Subject: QPID-6336: Add extra logging to help understand occasional SSLTest failure showing on slow CI box git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655485 13f79535-47bb-0310-9956-ffa450edef68 --- .../common/src/main/java/org/apache/qpid/transport/Connection.java | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index e33e007f6e..890aeda11b 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -537,6 +537,11 @@ public class Connection extends ConnectionInvoker connectionLost.set(true); synchronized (lock) { + if(log.isDebugEnabled()) + { + log.debug("exception: %s state : %s", e.getMessage(), state); + } + switch (state) { case OPENING: -- cgit v1.2.1 From 54b214dc8fd8087466cec5ee2dadaa60e797a49c Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Thu, 29 Jan 2015 22:13:14 +0000 Subject: QPID-6350: [Java Client] Preserve original connection exception git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1655877 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/transport/Connection.java | 10 +++++----- .../qpid/transport/network/security/ssl/SSLReceiver.java | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 890aeda11b..245f12ad0b 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -537,16 +537,16 @@ public class Connection extends ConnectionInvoker connectionLost.set(true); synchronized (lock) { - if(log.isDebugEnabled()) - { - log.debug("exception: %s state : %s", e.getMessage(), state); - } + log.error(e, "exception: %s", e.getMessage()); switch (state) { case OPENING: case CLOSING: - error = e; + if (error == null) + { + error = e; + } lock.notifyAll(); return; } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java index 1bbf166d82..8e1395aa83 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java @@ -187,7 +187,10 @@ public class SSLReceiver implements Receiver } catch(SSLException e) { - log.error(e, "Error caught in SSLReceiver"); + if (log.isDebugEnabled()) + { + log.debug(e, "Error caught in SSLReceiver"); + } _sslStatus.setSslErrorFlag(); synchronized(_sslStatus.getSslLock()) { -- cgit v1.2.1 From 050ccae5ceb3f9b077a797326b3ff604bf91a0b5 Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Wed, 4 Feb 2015 16:53:40 +0000 Subject: QPID-6350: [Java Client] Partial revert of r1655877. My solution was not solving the problem in all situations git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1657312 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/qpid/transport/Connection.java | 10 +++++----- .../qpid/transport/network/security/ssl/SSLReceiver.java | 5 +---- 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 245f12ad0b..890aeda11b 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -537,16 +537,16 @@ public class Connection extends ConnectionInvoker connectionLost.set(true); synchronized (lock) { - log.error(e, "exception: %s", e.getMessage()); + if(log.isDebugEnabled()) + { + log.debug("exception: %s state : %s", e.getMessage(), state); + } switch (state) { case OPENING: case CLOSING: - if (error == null) - { - error = e; - } + error = e; lock.notifyAll(); return; } diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java index 8e1395aa83..1bbf166d82 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java @@ -187,10 +187,7 @@ public class SSLReceiver implements Receiver } catch(SSLException e) { - if (log.isDebugEnabled()) - { - log.debug(e, "Error caught in SSLReceiver"); - } + log.error(e, "Error caught in SSLReceiver"); _sslStatus.setSslErrorFlag(); synchronized(_sslStatus.getSslLock()) { -- cgit v1.2.1 From bafd7f6d88ade9062a69ec78e3c3f3c4e5a7fe7b Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Wed, 4 Feb 2015 16:53:47 +0000 Subject: QPID-6350: [Java Common] Change IoSender to half close once writing is done. Change IoSender half close once it knows it has finished writing data down the pipe. This is done to prevent the peer from seeing sporadic socket exception 'connection resets' if it happens that the other side closes the socket first. If half close is not supported (windows platform or SSLSocket), this change has no effect. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1657313 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/qpid/transport/Connection.java | 5 +---- .../apache/qpid/transport/network/io/IoSender.java | 21 +++++++++++++++++++++ .../transport/network/security/ssl/SSLReceiver.java | 5 ++++- .../transport/network/security/ssl/SSLSender.java | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java index 890aeda11b..e63949cc69 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java @@ -537,10 +537,7 @@ public class Connection extends ConnectionInvoker connectionLost.set(true); synchronized (lock) { - if(log.isDebugEnabled()) - { - log.debug("exception: %s state : %s", e.getMessage(), state); - } + log.error(e, "exception: %s", e.getMessage()); switch (state) { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java index e06782c58a..25222e5285 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/io/IoSender.java @@ -26,12 +26,15 @@ import java.net.Socket; import java.nio.ByteBuffer; import java.util.concurrent.atomic.AtomicBoolean; +import javax.net.ssl.SSLSocket; + import org.apache.qpid.thread.Threading; import org.apache.qpid.transport.Sender; import org.apache.qpid.transport.SenderClosedException; import org.apache.qpid.transport.SenderException; import org.apache.qpid.transport.TransportException; import org.apache.qpid.transport.util.Logger; +import org.apache.qpid.util.SystemUtils; public final class IoSender implements Runnable, Sender @@ -58,6 +61,12 @@ public final class IoSender implements Runnable, Sender private final Thread senderThread; private IoReceiver _receiver; private final String _remoteSocketAddress; + private static final boolean shutdownBroken; + + static + { + shutdownBroken = SystemUtils.isWindows(); + } private volatile Throwable exception = null; @@ -314,6 +323,18 @@ public final class IoSender implements Runnable, Sender } } } + + if (!shutdownBroken && !(socket instanceof SSLSocket)) + { + try + { + socket.shutdownOutput(); + } + catch (IOException e) + { + //pass + } + } } public void setIdleTimeout(int i) diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java index 1bbf166d82..8e1395aa83 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLReceiver.java @@ -187,7 +187,10 @@ public class SSLReceiver implements Receiver } catch(SSLException e) { - log.error(e, "Error caught in SSLReceiver"); + if (log.isDebugEnabled()) + { + log.debug(e, "Error caught in SSLReceiver"); + } _sslStatus.setSslErrorFlag(); synchronized(_sslStatus.getSslLock()) { diff --git a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java index 7c61136b42..53bd7e49b7 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/ssl/SSLSender.java @@ -141,7 +141,7 @@ public class SSLSender implements Sender public void send(ByteBuffer appData) { - if (closed.get()) + if (closed.get() && !_sslStatus.getSslErrorFlag()) { throw new SenderException("SSL Sender is closed"); } -- cgit v1.2.1 From bd9ca7255cd5c08ec348dd5976249e0a8dd1a8bc Mon Sep 17 00:00:00 2001 From: Keith Wall Date: Sat, 7 Feb 2015 19:09:18 +0000 Subject: QPID-6371: [Java Broker/Java Common] Prevent log4j warning during Broker startup git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1658098 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/qpid/common/QpidProperties.java | 76 ++++------------------ 1 file changed, 13 insertions(+), 63 deletions(-) (limited to 'qpid/java/common/src') diff --git a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java index 74219f216e..d077cc9717 100644 --- a/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java +++ b/qpid/java/common/src/main/java/org/apache/qpid/common/QpidProperties.java @@ -22,12 +22,8 @@ package org.apache.qpid.common; import java.io.IOException; import java.io.InputStream; -import java.util.Map; import java.util.Properties; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * QpidProperties captures the project name, version number, and source code repository revision number from a properties * file which is generated as part of the build process. Normally, the name and version number are pulled from the module @@ -37,18 +33,9 @@ import org.slf4j.LoggerFactory; * *

To get the build version of any Qpid code call the {@link #main} method. This version string is usually also * printed to the console on broker start up. - *

- * TODO Code to locate/load/log properties can be factored into a reusable properties utils class. Avoid having this - * same snippet of loading code scattered in many places. - *

- * TODO Could also add a build number property for a sequential build number assigned by an automated build system, for - * build reproducability purposes. */ public class QpidProperties { - /** Used for debugging purposes. */ - private static final Logger _logger = LoggerFactory.getLogger(QpidProperties.class); - /** The name of the version properties file to load from the class path. */ public static final String VERSION_RESOURCE = "qpidversion.properties"; @@ -68,13 +55,13 @@ public class QpidProperties private static final String DEFAULT = "unknown"; /** Holds the product name. */ - private static String productName = DEFAULT; + private static final String productName; /** Holds the product version. */ - private static String releaseVersion = DEFAULT; + private static final String releaseVersion; /** Holds the source code revision. */ - private static String buildVersion = DEFAULT; + private static final String buildVersion; private static final Properties properties = new Properties(); @@ -82,40 +69,24 @@ public class QpidProperties static { - try + try(InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE)) { - InputStream propertyStream = QpidProperties.class.getClassLoader().getResourceAsStream(VERSION_RESOURCE); - if (propertyStream == null) - { - _logger.warn("Unable to find resource " + VERSION_RESOURCE + " from classloader"); - } - else + if (propertyStream != null) { properties.load(propertyStream); - - if (_logger.isDebugEnabled()) - { - _logger.debug("Dumping QpidProperties"); - for (Map.Entry entry : properties.entrySet()) - { - _logger.debug("Property: " + entry.getKey() + " Value: " + entry.getValue()); - } - - _logger.debug("End of property dump"); - } - - productName = readPropertyValue(properties, PRODUCT_NAME_PROPERTY); - String versionSuffix = (String) properties.get(RELEASE_VERSION_SUFFIX); - String version = readPropertyValue(properties, RELEASE_VERSION_PROPERTY); - releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix; - buildVersion = readPropertyValue(properties, BUILD_VERSION_PROPERTY); } } catch (IOException e) { - // Log a warning about this and leave the values initialized to unknown. - _logger.error("Could not load version.properties resource: " + e, e); + // Ignore, most likely running within an IDE, values will have the DEFAULT text } + + String versionSuffix = properties.getProperty(RELEASE_VERSION_SUFFIX); + String version = properties.getProperty(RELEASE_VERSION_PROPERTY, DEFAULT); + + productName = properties.getProperty(PRODUCT_NAME_PROPERTY, DEFAULT); + releaseVersion = versionSuffix == null || "".equals(versionSuffix) ? version : version + ";" + versionSuffix; + buildVersion = properties.getProperty(BUILD_VERSION_PROPERTY, DEFAULT); } public static Properties asProperties() @@ -163,27 +134,6 @@ public class QpidProperties return getProductName() + " - " + getReleaseVersion() + " build: " + getBuildVersion(); } - /** - * Helper method to extract a named property from properties. - * - * @param props The properties. - * @param propertyName The named property to extract. - * - * @return The extracted property or a default value if the properties do not contain the named property. - * - * @todo A bit pointless. - */ - private static String readPropertyValue(Properties props, String propertyName) - { - String retVal = (String) props.get(propertyName); - if (retVal == null) - { - retVal = DEFAULT; - } - - return retVal; - } - /** * Prints the versioning information to the console. This is extremely usefull for identifying Qpid code in the * wild, where the origination of the code has been forgotten. -- cgit v1.2.1