This is an automated email from the ASF dual-hosted git repository.
kenhuuu pushed a commit to branch master-http
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
The following commit(s) were added to refs/heads/master-http by this push:
new 9efc323f7e Fix incorrect ResponseMessage in
TextPlainMessageSerializerV4Test CTR
9efc323f7e is described below
commit 9efc323f7eadfdc24b6c2c78af7e6e2d30d092b2
Author: Ken Hu <[email protected]>
AuthorDate: Tue May 14 21:35:28 2024 -0700
Fix incorrect ResponseMessage in TextPlainMessageSerializerV4Test CTR
---
.../server/util/TextPlainMessageSerializerV4.java | 29 +++++++++++-----------
.../util/TextPlainMessageSerializerV4Test.java | 2 ++
2 files changed, 16 insertions(+), 15 deletions(-)
diff --git
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java
index 6bdfbf0e54..dadd1eb468 100644
---
a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java
+++
b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4.java
@@ -27,7 +27,6 @@ import
org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4;
import org.apache.tinkerpop.gremlin.util.ser.AbstractMessageSerializerV4;
import org.apache.tinkerpop.gremlin.util.ser.SerializationException;
-import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.function.Function;
@@ -44,49 +43,49 @@ public class TextPlainMessageSerializerV4 extends
AbstractMessageSerializerV4<Fu
}
@Override
- public ByteBuf serializeResponseAsBinary(final ResponseMessageV4
responseMessage, final ByteBufAllocator allocator) throws
SerializationException {
+ public ByteBuf serializeResponseAsBinary(final ResponseMessageV4
responseMessage, final ByteBufAllocator allocator) {
return (responseMessage.getStatus().getCode() == HttpResponseStatus.OK)
- ? convertStringData((List<Object>)
responseMessage.getResult().getData(), false, allocator)
+ ? convertStringData(responseMessage.getResult().getData(),
false, allocator)
: convertErrorString(responseMessage.getStatus().getMessage(),
allocator);
}
@Override
- public ByteBuf writeHeader(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) throws SerializationException {
- return convertStringData((List<Object>)
responseMessage.getResult().getData(), false, allocator);
+ public ByteBuf writeHeader(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) {
+ return convertStringData(responseMessage.getResult().getData(), false,
allocator);
}
@Override
- public ByteBuf writeChunk(Object aggregate, ByteBufAllocator allocator)
throws SerializationException {
+ public ByteBuf writeChunk(Object aggregate, ByteBufAllocator allocator) {
return convertStringData((List<Object>) aggregate, true, allocator);
}
@Override
- public ByteBuf writeFooter(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) throws SerializationException {
- return convertStringData((List<Object>)
responseMessage.getResult().getData(), true, allocator);
+ public ByteBuf writeFooter(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) {
+ return convertStringData(responseMessage.getResult().getData(), true,
allocator);
}
@Override
- public ByteBuf writeErrorFooter(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) throws SerializationException {
+ public ByteBuf writeErrorFooter(ResponseMessageV4 responseMessage,
ByteBufAllocator allocator) {
return convertErrorString(System.lineSeparator() +
responseMessage.getStatus().getMessage(), allocator);
}
@Override
- public ResponseMessageV4 readChunk(ByteBuf byteBuf, boolean isFirstChunk)
throws SerializationException {
+ public ResponseMessageV4 readChunk(ByteBuf byteBuf, boolean isFirstChunk) {
throw new UnsupportedOperationException("text/plain does not have
deserialization functions");
}
@Override
- public ByteBuf serializeRequestAsBinary(final RequestMessageV4
requestMessage, final ByteBufAllocator allocator) throws SerializationException
{
+ public ByteBuf serializeRequestAsBinary(final RequestMessageV4
requestMessage, final ByteBufAllocator allocator) {
throw new UnsupportedOperationException("text/plain does not produce
binary");
}
@Override
- public RequestMessageV4 deserializeBinaryRequest(final ByteBuf msg) throws
SerializationException {
+ public RequestMessageV4 deserializeBinaryRequest(final ByteBuf msg) {
throw new UnsupportedOperationException("text/plain does not have
deserialization functions");
}
@Override
- public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg)
throws SerializationException {
+ public ResponseMessageV4 deserializeBinaryResponse(final ByteBuf msg) {
throw new UnsupportedOperationException("text/plain does not have
deserialization functions");
}
@@ -95,7 +94,7 @@ public class TextPlainMessageSerializerV4 extends
AbstractMessageSerializerV4<Fu
return new String[] { "text/plain" };
}
- private ByteBuf convertStringData(final List<Object> data, final boolean
addStartingSeparator, final ByteBufAllocator allocator) throws
SerializationException {
+ private ByteBuf convertStringData(final List<Object> data, final boolean
addStartingSeparator, final ByteBufAllocator allocator) {
final StringBuilder sb = new StringBuilder();
if (addStartingSeparator) sb.append(System.lineSeparator());
@@ -113,7 +112,7 @@ public class TextPlainMessageSerializerV4 extends
AbstractMessageSerializerV4<Fu
return encodedMessage;
}
- private ByteBuf convertErrorString(final String error, final
ByteBufAllocator allocator) throws SerializationException {
+ private ByteBuf convertErrorString(final String error, final
ByteBufAllocator allocator) {
final ByteBuf encodedMessage = allocator.buffer(error.length());
encodedMessage.writeCharSequence(error, CharsetUtil.UTF_8);
return encodedMessage;
diff --git
a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java
index 09d7cecc7f..4fda9ae89d 100644
---
a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java
+++
b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/util/TextPlainMessageSerializerV4Test.java
@@ -20,6 +20,7 @@ package org.apache.tinkerpop.gremlin.server.util;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
+import io.netty.handler.codec.http.HttpResponseStatus;
import io.netty.util.CharsetUtil;
import org.apache.tinkerpop.gremlin.structure.util.detached.DetachedVertex;
import org.apache.tinkerpop.gremlin.util.message.ResponseMessageV4;
@@ -36,6 +37,7 @@ public class TextPlainMessageSerializerV4Test {
public void shouldProducePlainText() throws Exception {
final Map<String, Object> m = new HashMap<>();
final ResponseMessageV4 msg = ResponseMessageV4.build().
+ code(HttpResponseStatus.OK).
result(Arrays.asList(1, new DetachedVertex(100, "person", m),
java.awt.Color.RED)).create();
final TextPlainMessageSerializerV4 messageSerializer = new
TextPlainMessageSerializerV4();