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 2022/09/13 21:18:24 UTC
[activemq-artemis] branch 2.25.x updated (a81538c2fc -> 48fccc52dd)
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a change to branch 2.25.x
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
from a81538c2fc ARTEMIS-3989 ActiveMQServerControl.getRoles doesn't return all roles
new a08b42c007 NO-JIRA Removing dead code - AmqpReadableBuffer
new 48fccc52dd ARTEMIS-3990 Ensure that readable buffer string read consumes the bytes
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../protocol/amqp/broker/AmqpReadableBuffer.java | 227 ---------------------
.../artemis/protocol/amqp/util/NettyReadable.java | 4 +-
.../protocol/amqp/util/NettyReadableTest.java | 4 +
3 files changed, 6 insertions(+), 229 deletions(-)
delete mode 100644 artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AmqpReadableBuffer.java
[activemq-artemis] 02/02: ARTEMIS-3990 Ensure that readable buffer string read consumes the bytes
Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch 2.25.x
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit 48fccc52dd4d93b997c6a5132f4004bfb0a58319
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Tue Sep 13 16:21:34 2022 -0400
ARTEMIS-3990 Ensure that readable buffer string read consumes the bytes
Ensures that when reading a string the readable buffer consumes the
bytes by advancing the read index as defined in the interface API docs.
(cherry picked from commit 289587f004ac46f7c175c9daa1585695cf9df917)
---
.../org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java | 4 ++--
.../apache/activemq/artemis/protocol/amqp/util/NettyReadableTest.java | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
index b0679b5a68..6b14575f07 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadable.java
@@ -145,7 +145,7 @@ public class NettyReadable implements ReadableBuffer {
@Override
public String readUTF8() {
- return buffer.toString(Charset_UTF8);
+ return buffer.readCharSequence(buffer.readableBytes(), Charset_UTF8).toString();
}
@Override
@@ -192,7 +192,7 @@ public class NettyReadable implements ReadableBuffer {
@Override
public String readString(CharsetDecoder decoder) throws CharacterCodingException {
- return buffer.toString(decoder.charset());
+ return buffer.readCharSequence(buffer.readableBytes(), decoder.charset()).toString();
}
@Override
diff --git a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadableTest.java b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadableTest.java
index 437d57b549..c3d473b288 100644
--- a/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadableTest.java
+++ b/artemis-protocols/artemis-amqp-protocol/src/test/java/org/apache/activemq/artemis/protocol/amqp/util/NettyReadableTest.java
@@ -438,7 +438,9 @@ public class NettyReadableTest {
NettyReadable buffer = new NettyReadable(byteBuffer);
+ assertEquals(asUtf8bytes.length, buffer.remaining());
assertEquals(testString, buffer.readUTF8());
+ assertEquals(0, buffer.remaining());
}
@Test
@@ -449,6 +451,8 @@ public class NettyReadableTest {
NettyReadable buffer = new NettyReadable(byteBuffer);
+ assertEquals(asUtf8bytes.length, buffer.remaining());
assertEquals(testString, buffer.readString(StandardCharsets.UTF_8.newDecoder()));
+ assertEquals(0, buffer.remaining());
}
}
[activemq-artemis] 01/02: NO-JIRA Removing dead code - AmqpReadableBuffer
Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch 2.25.x
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
commit a08b42c007475df72c2e239b8996357e1f9491ee
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue Sep 13 17:16:51 2022 -0400
NO-JIRA Removing dead code - AmqpReadableBuffer
(cherry picked from commit 902c0cb62b8685ce2b3c1792913847a377387d9c)
---
.../protocol/amqp/broker/AmqpReadableBuffer.java | 227 ---------------------
1 file changed, 227 deletions(-)
diff --git a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AmqpReadableBuffer.java b/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AmqpReadableBuffer.java
deleted file mode 100644
index 0cdae0f920..0000000000
--- a/artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AmqpReadableBuffer.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF 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.apache.activemq.artemis.protocol.amqp.broker;
-
-import java.nio.ByteBuffer;
-import java.nio.charset.CharacterCodingException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.StandardCharsets;
-
-import io.netty.buffer.ByteBuf;
-import io.netty.buffer.Unpooled;
-import io.netty.util.internal.PlatformDependent;
-import org.apache.qpid.proton.codec.ReadableBuffer;
-import org.apache.qpid.proton.codec.WritableBuffer;
-
-public class AmqpReadableBuffer implements ReadableBuffer {
- private ByteBuffer buffer;
-
- public AmqpReadableBuffer(ByteBuffer buffer) {
- this.buffer = buffer;
- }
-
- public ByteBuffer getBuffer() {
- return this.buffer;
- }
-
- @Override
- public int capacity() {
- return this.buffer.capacity();
- }
-
- @Override
- public boolean hasArray() {
- return this.buffer.hasArray();
- }
-
- @Override
- public byte[] array() {
- if (this.buffer.hasArray()) {
- return this.buffer.array();
- } else {
- byte[] bytes = new byte[buffer.remaining()];
- buffer.get(bytes);
- return bytes;
- }
- }
-
- public void freeDirectBuffer() {
- // releasing direct buffer created from mmap
- PlatformDependent.freeDirectBuffer(buffer);
- }
-
- @Override
- public int arrayOffset() {
- return this.buffer.arrayOffset();
- }
-
- @Override
- public ReadableBuffer reclaimRead() {
- return this;
- }
-
- @Override
- public byte get() {
- return this.buffer.get();
- }
-
- @Override
- public byte get(int index) {
- return this.buffer.get(index);
- }
-
- @Override
- public int getInt() {
- return this.buffer.getInt();
- }
-
- @Override
- public long getLong() {
- return this.buffer.getLong();
- }
-
- @Override
- public short getShort() {
- return this.buffer.getShort();
- }
-
- @Override
- public float getFloat() {
- return this.buffer.getFloat();
- }
-
- @Override
- public double getDouble() {
- return this.buffer.getDouble();
- }
-
- @Override
- public ReadableBuffer get(byte[] target, int offset, int length) {
- this.buffer.get(target, offset, length);
- return this;
- }
-
- @Override
- public ReadableBuffer get(byte[] target) {
- this.buffer.get(target);
- return this;
- }
-
- @Override
- public ReadableBuffer get(WritableBuffer target) {
- int start = target.position();
- if (this.buffer.hasArray()) {
- target.put(this.buffer.array(), this.buffer.arrayOffset() + this.buffer.position(), this.buffer.remaining());
- } else {
- target.put(this.buffer);
- }
-
- int written = target.position() - start;
- this.buffer.position(this.buffer.position() + written);
- return this;
- }
-
- @Override
- public ReadableBuffer slice() {
- return new AmqpReadableBuffer(this.buffer.slice());
- }
-
- @Override
- public ReadableBuffer flip() {
- this.buffer.flip();
- return this;
- }
-
- @Override
- public ReadableBuffer limit(int limit) {
- this.buffer.limit(limit);
- return this;
- }
-
- @Override
- public int limit() {
- return this.buffer.limit();
- }
-
- @Override
- public ReadableBuffer position(int position) {
- this.buffer.position(position);
- return this;
- }
-
- @Override
- public int position() {
- return this.buffer.position();
- }
-
- @Override
- public ReadableBuffer mark() {
- this.buffer.mark();
- return this;
- }
-
- @Override
- public ReadableBuffer reset() {
- this.buffer.reset();
- return this;
- }
-
- @Override
- public ReadableBuffer rewind() {
- this.buffer.rewind();
- return this;
- }
-
- @Override
- public ReadableBuffer clear() {
- this.buffer.clear();
- return this;
- }
-
- @Override
- public int remaining() {
- return this.buffer.remaining();
- }
-
- @Override
- public boolean hasRemaining() {
- return this.buffer.hasRemaining();
- }
-
- @Override
- public ReadableBuffer duplicate() {
- return new AmqpReadableBuffer(this.buffer.duplicate());
- }
-
- @Override
- public ByteBuffer byteBuffer() {
- return this.buffer;
- }
-
- @Override
- public String readUTF8() throws CharacterCodingException {
- ByteBuf wrappedNetty = Unpooled.wrappedBuffer(buffer);
- return wrappedNetty.toString(StandardCharsets.UTF_8);
- }
-
- @Override
- public String readString(CharsetDecoder decoder) throws CharacterCodingException {
- ByteBuf wrappedNetty = Unpooled.wrappedBuffer(buffer);
- return wrappedNetty.toString(StandardCharsets.UTF_8);
- }
-}