mirror of https://github.com/apache/activemq.git
apply patch (with modification to fix a null pointer violation case) fixes: https://issues.apache.org/activemq/browse/AMQ-2990
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1025620 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7055fb98c4
commit
a60eeaa7ae
|
@ -38,10 +38,9 @@ import org.apache.activemq.util.IOExceptionSupport;
|
||||||
*/
|
*/
|
||||||
public class ActiveMQOutputStream extends OutputStream implements Disposable {
|
public class ActiveMQOutputStream extends OutputStream implements Disposable {
|
||||||
|
|
||||||
// Send down 64k messages.
|
|
||||||
protected int count;
|
protected int count;
|
||||||
|
|
||||||
final byte buffer[] = new byte[64 * 1024];
|
final byte buffer[];
|
||||||
|
|
||||||
private final ActiveMQConnection connection;
|
private final ActiveMQConnection connection;
|
||||||
private final Map<String, Object> properties;
|
private final Map<String, Object> properties;
|
||||||
|
@ -53,6 +52,11 @@ public class ActiveMQOutputStream extends OutputStream implements Disposable {
|
||||||
private final int priority;
|
private final int priority;
|
||||||
private final long timeToLive;
|
private final long timeToLive;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* JMS Property which is used to specify the size (in kb) which is used as chunk size when splitting the stream. Default is 64kb
|
||||||
|
*/
|
||||||
|
public final static String AMQ_STREAM_CHUNK_SIZE = "AMQ_STREAM_CHUNK_SIZE";
|
||||||
|
|
||||||
public ActiveMQOutputStream(ActiveMQConnection connection, ProducerId producerId, ActiveMQDestination destination, Map<String, Object> properties, int deliveryMode, int priority,
|
public ActiveMQOutputStream(ActiveMQConnection connection, ProducerId producerId, ActiveMQDestination destination, Map<String, Object> properties, int deliveryMode, int priority,
|
||||||
long timeToLive) throws JMSException {
|
long timeToLive) throws JMSException {
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
@ -61,6 +65,19 @@ public class ActiveMQOutputStream extends OutputStream implements Disposable {
|
||||||
this.timeToLive = timeToLive;
|
this.timeToLive = timeToLive;
|
||||||
this.properties = properties == null ? null : new HashMap<String, Object>(properties);
|
this.properties = properties == null ? null : new HashMap<String, Object>(properties);
|
||||||
|
|
||||||
|
Integer chunkSize = this.properties == null ? null : (Integer) this.properties.get(AMQ_STREAM_CHUNK_SIZE);
|
||||||
|
if (chunkSize == null) {
|
||||||
|
chunkSize = 64 * 1024;
|
||||||
|
} else {
|
||||||
|
if (chunkSize < 1) {
|
||||||
|
throw new IllegalArgumentException("Chunk size must be greater then 0");
|
||||||
|
} else {
|
||||||
|
chunkSize *= 1024;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer = new byte[chunkSize];
|
||||||
|
|
||||||
if (destination == null) {
|
if (destination == null) {
|
||||||
throw new InvalidDestinationException("Don't understand null destinations");
|
throw new InvalidDestinationException("Don't understand null destinations");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue