You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2018/03/20 19:54:43 UTC
[1/3] activemq-artemis git commit: ARTEMIS-1754
LargeServerMessageImpl.toString() may leak files
Repository: activemq-artemis
Updated Branches:
refs/heads/master 8b8eff053 -> d3b11bc43
ARTEMIS-1754 LargeServerMessageImpl.toString() may leak files
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/38ba5d79
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/38ba5d79
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/38ba5d79
Branch: refs/heads/master
Commit: 38ba5d797a18d99447f42f7790446c0009dc44d7
Parents: 8b8eff0
Author: Howard Gao <ho...@gmail.com>
Authored: Tue Mar 20 21:54:41 2018 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 20 15:40:44 2018 -0400
----------------------------------------------------------------------
.../core/persistence/impl/journal/LargeServerMessageImpl.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/38ba5d79/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index 9a2e285..297328d 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -355,7 +355,7 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
@Override
public String toString() {
try {
- return "LargeServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + ", durable=" + durable + ", address=" + getAddress() + ",size=" + getPersistentSize() + ",properties=" + (properties != null ? properties.toString() : "") + "]@" + System.identityHashCode(this);
+ return "LargeServerMessage[messageID=" + messageID + ",durable=" + isDurable() + ",userID=" + getUserID() + ",priority=" + this.getPriority() + ", timestamp=" + toDate(getTimestamp()) + ",expiration=" + toDate(getExpiration()) + ", durable=" + durable + ", address=" + getAddress() + ", properties=" + (properties != null ? properties.toString() : "") + "]@" + System.identityHashCode(this);
} catch (Exception e) {
e.printStackTrace();
return "LargeServerMessage[messageID=" + messageID + "]";
[3/3] activemq-artemis git commit: This closes #1959
Posted by cl...@apache.org.
This closes #1959
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/d3b11bc4
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/d3b11bc4
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/d3b11bc4
Branch: refs/heads/master
Commit: d3b11bc439d7fdbefe6294ce625ef7dbb5b47c62
Parents: 8b8eff0 fe0e6c2
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Mar 20 15:54:33 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 20 15:54:33 2018 -0400
----------------------------------------------------------------------
.../artemis/core/message/LargeBodyEncoder.java | 2 +-
.../impl/journal/LargeServerMessageImpl.java | 43 +++++++++++++-------
.../core/server/impl/ServerConsumerImpl.java | 1 +
3 files changed, 30 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
[2/3] activemq-artemis git commit: ARTEMIS-1754 Avoiding Leaks from
LargeServerMessageImpl.getPersistentSize
Posted by cl...@apache.org.
ARTEMIS-1754 Avoiding Leaks from LargeServerMessageImpl.getPersistentSize
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/fe0e6c2b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fe0e6c2b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fe0e6c2b
Branch: refs/heads/master
Commit: fe0e6c2b287e623cf9a50c00764bbc53624fdc9f
Parents: 38ba5d7
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Mar 20 15:40:33 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Mar 20 15:45:09 2018 -0400
----------------------------------------------------------------------
.../artemis/core/message/LargeBodyEncoder.java | 2 +-
.../impl/journal/LargeServerMessageImpl.java | 41 +++++++++++++-------
.../core/server/impl/ServerConsumerImpl.java | 1 +
3 files changed, 29 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe0e6c2b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
index 8b96282..7a248b4 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/message/LargeBodyEncoder.java
@@ -51,5 +51,5 @@ public interface LargeBodyEncoder {
/**
* This method must not be called directly by ActiveMQ Artemis clients.
*/
- long getLargeBodySize();
+ long getLargeBodySize() throws ActiveMQException;
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe0e6c2b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
index 297328d..940f8b0 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/LargeServerMessageImpl.java
@@ -22,6 +22,7 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
+import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
import org.apache.activemq.artemis.api.core.ActiveMQInternalErrorException;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.core.buffers.impl.ChannelBufferWrapper;
@@ -238,10 +239,7 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
public synchronized int getMemoryEstimate() {
if (memoryEstimate == -1) {
// The body won't be on memory (aways on-file), so we don't consider this for paging
- memoryEstimate = getHeadersAndPropertiesEncodeSize() + DataConstants.SIZE_INT +
- getEncodeSize() +
- (16 + 4) * 2 +
- 1;
+ memoryEstimate = getHeadersAndPropertiesEncodeSize() + DataConstants.SIZE_INT + getEncodeSize() + (16 + 4) * 2 + 1;
}
return memoryEstimate;
@@ -345,13 +343,35 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
return file;
}
+ private long getBodySize() throws ActiveMQException {
+
+ try {
+ if (bodySize < 0) {
+ if (file != null) {
+ bodySize = file.size();
+ } else {
+ SequentialFile tmpFile = createFile();
+ bodySize = tmpFile.size();
+ tmpFile.close();
+ }
+ }
+ return bodySize;
+ } catch (Exception e) {
+ ActiveMQIOErrorException errorException = new ActiveMQIOErrorException();
+ errorException.initCause(e);
+ throw errorException;
+ }
+ }
+
@Override
public long getPersistentSize() throws ActiveMQException {
long size = super.getPersistentSize();
- size += getBodyEncoder().getLargeBodySize();
+ size += getBodySize();
return size;
+
}
+
@Override
public String toString() {
try {
@@ -463,15 +483,8 @@ public final class LargeServerMessageImpl extends CoreMessage implements LargeSe
* @see org.apache.activemq.artemis.core.message.LargeBodyEncoder#getLargeBodySize()
*/
@Override
- public long getLargeBodySize() {
- if (bodySize < 0) {
- try {
- bodySize = file.size();
- } catch (Exception e) {
- ActiveMQServerLogger.LOGGER.unableToCalculateFileSize(e);
- }
- }
- return bodySize;
+ public long getLargeBodySize() throws ActiveMQException {
+ return getBodySize();
}
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fe0e6c2b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
index 95d613e..8ef0fa1 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerConsumerImpl.java
@@ -1305,6 +1305,7 @@ public class ServerConsumerImpl implements ServerConsumer, ReadyListener {
}
if (context != null) {
context.close();
+ context = null;
}
largeMessage.releaseResources();