[
https://issues.apache.org/jira/browse/BEAM-12474?focusedWorklogId=620168&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-620168
]
ASF GitHub Bot logged work on BEAM-12474:
-----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Jul/21 19:07
Start Date: 07/Jul/21 19:07
Worklog Time Spent: 10m
Work Description: zhoufek commented on a change in pull request #15037:
URL: https://github.com/apache/beam/pull/15037#discussion_r665636511
##########
File path:
sdks/java/core/src/main/java/org/apache/beam/sdk/util/ComparableThrowable.java
##########
@@ -0,0 +1,112 @@
+/*
+ * 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.beam.sdk.util;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import javax.annotation.Nullable;
+
+/**
+ * A wrapper around a {@link Throwable} for use with coders.
+ *
+ * <p>The {@link Throwable} class is serializable. However, it, along with man
child classes like
+ * {@link Exception}, does not override {@link Object#equals(Object)}. As a
result, t1.equals(t2)
+ * will return false if t2 is a deserialized instance of serialized t1. This
makes it appear as if
+ * coders are mutating the value, which can lead to things like log spam. This
wrapper overrides
+ * {@link Object#equals(Object)} to get around this issue. The hash code
remains the same as the
+ * underlying {@link Throwable}.
+ *
+ * <p>The equality comparison is transitive, meaning that for two {@link
Throwable}s t1 and t2, the
+ * causes must be equal. This can occur either because they are both null or
because they are both
+ * equal after being wrapped.
+ *
+ * <p>Note that this is simply a best effort based on properties like instance
type, stack trace,
+ * message, and cause. It cannot guarantee that the state that led to the
exception is the same,
+ * unless it is fully captured in the message, nor can it differentiate
between two exceptions
+ * thrown at different times or in different processes. For this reason, this
is not suitable for a
+ * general-purpose {@link Throwable} equality comparison. It merely exists to
try to avoid false
+ * positives in a mutation check for coders.
+ *
+ * <p>Due to the above, this does not support comparison to a raw {@link
Throwable}.
+ */
+public class ComparableThrowable implements Serializable {
Review comment:
Maybe `EncodableThrowable`? Since `Throwable` is already a serializable
type, and the real purpose is for safer use with coders, which use
encode/decode.
Also, I'll be changing the class to be final to avoid potential issues with
`equals` inheritance. (I don't think I had any reason to not mark it final. I
think I just forgot to do so.)
--
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]
Issue Time Tracking
-------------------
Worklog Id: (was: 620168)
Time Spent: 4h 50m (was: 4h 40m)
> Configure PubsubIO with dead-letter topic
> -----------------------------------------
>
> Key: BEAM-12474
> URL: https://issues.apache.org/jira/browse/BEAM-12474
> Project: Beam
> Issue Type: Improvement
> Components: io-java-gcp
> Reporter: Zachary Houfek
> Assignee: Zachary Houfek
> Priority: P2
> Time Spent: 4h 50m
> Remaining Estimate: 0h
>
> Based on discussion from [PR14971|https://github.com/apache/beam/pull/14971].
> Currently, PubsubIO throws a RuntimeException when it can't parse a payload.
> It would perhaps be helpful if users could configure PubsubIO.Read with a
> dead-letter topic so that parsing errors instead write to the topic rather
> than just throw an exception.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)