Abacn commented on code in PR #31618:
URL: https://github.com/apache/beam/pull/31618#discussion_r1643388295
##########
sdks/java/io/rabbitmq/src/main/java/org/apache/beam/sdk/io/rabbitmq/RabbitMqMessage.java:
##########
@@ -78,30 +80,37 @@ private static Map<String, Object>
serializableHeaders(Map<String, Object> heade
if (headers != null) {
for (Map.Entry<String, Object> h : headers.entrySet()) {
Object value = h.getValue();
- if (!(value instanceof Serializable)) {
- try {
- if (value instanceof LongString) {
- LongString longString = (LongString) value;
Review Comment:
I'm not sure why this was splitted to 4 lines. Persumably this makes error
stack trace, if happens, more obvious which operation has problem?
##########
sdks/java/io/rabbitmq/src/main/java/org/apache/beam/sdk/io/rabbitmq/RabbitMqMessage.java:
##########
@@ -78,30 +80,37 @@ private static Map<String, Object>
serializableHeaders(Map<String, Object> heade
if (headers != null) {
for (Map.Entry<String, Object> h : headers.entrySet()) {
Object value = h.getValue();
- if (!(value instanceof Serializable)) {
- try {
- if (value instanceof LongString) {
- LongString longString = (LongString) value;
- byte[] bytes = longString.getBytes();
- String s = new String(bytes, StandardCharsets.UTF_8);
- value = s;
- } else {
- throw new RuntimeException(String.format("no transformation
defined for %s", value));
- }
- } catch (Throwable t) {
- throw new UnsupportedOperationException(
- String.format(
- "can't make unserializable value %s a serializable value
(which is mandatory for Apache Beam dataflow implementation)",
- value),
- t);
- }
+ if (value instanceof List<?>) {
Review Comment:
Would be great if we can unit testing this. this is a static method and
return type is Map<String, Object>, we should be able to use setup some sample
data, and change the scope of this method to ```
@VisibleForTesting
static ...
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]