You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2019/01/22 23:53:14 UTC
[tinkerpop] 01/01: TINKERPOP-2126 Fixed concurrency issue in
`ObjectWritable::toString()`.
This is an automated email from the ASF dual-hosted git repository.
dkuppitz pushed a commit to branch TINKERPOP-2126
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git
commit 960ec6071dfc323a373fb8b7f83e657e336acd08
Author: Daniel Kuppitz <da...@hotmail.com>
AuthorDate: Tue Jan 22 15:07:09 2019 -0700
TINKERPOP-2126 Fixed concurrency issue in `ObjectWritable::toString()`.
---
CHANGELOG.asciidoc | 2 +-
.../gremlin/hadoop/structure/io/ObjectWritable.java | 15 ++++++++++++---
2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 1b0f79b..eac7a9b 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -24,7 +24,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
=== TinkerPop 3.3.6 (Release Date: NOT OFFICIALLY RELEASED YET)
* Masked sensitive configuration options in the logs of `KryoShimServiceLoader`.
-* Fixed a concurrency issue in `TraverserSet`
+* Fixed concurrency issues in `TraverserSet::toString()` and `ObjectWritable::toString()`.
* Fixed a bug in `InlineFilterStrategy` that mixed up and's and or's when folding merging conditions together.
[[release-3-3-5]]
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
index 0379ee6..13cea4e 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/structure/io/ObjectWritable.java
@@ -30,13 +30,14 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
+import java.util.ConcurrentModificationException;
+import java.util.Objects;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public final class ObjectWritable<T> implements WritableComparable<ObjectWritable>, Serializable {
- private static final String NULL = "null";
private static final ObjectWritable<MapReduce.NullObject> NULL_OBJECT_WRITABLE = new ObjectWritable<>(MapReduce.NullObject.instance());
T t;
@@ -45,7 +46,7 @@ public final class ObjectWritable<T> implements WritableComparable<ObjectWritabl
}
public ObjectWritable(final T t) {
- this.t = t;
+ this.set(t);
}
public T get() {
@@ -58,7 +59,15 @@ public final class ObjectWritable<T> implements WritableComparable<ObjectWritabl
@Override
public String toString() {
- return null == this.t ? NULL : this.t.toString();
+ // Spark's background logging apparently tries to log a `toString()` of certain objects while they're being
+ // modified, which then throws a ConcurrentModificationException. We probably can't make any arbitrary object
+ // thread-safe, but we can easily retry on such cases and eventually we should always get a result.
+ while (true) {
+ try {
+ return Objects.toString(this.t);
+ }
+ catch (ConcurrentModificationException ignored) { }
+ }
}
@Override