[
https://issues.apache.org/jira/browse/FLINK-10412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16656831#comment-16656831
]
ASF GitHub Bot commented on FLINK-10412:
----------------------------------------
asfgit closed pull request #6755: [FLINK-10412] toString field in AbstractID
should be transient to avoid been serialized
URL: https://github.com/apache/flink/pull/6755
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
index 41083c60783..b7be21a3a57 100644
--- a/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
+++ b/flink-core/src/main/java/org/apache/flink/util/AbstractID.java
@@ -47,7 +47,7 @@
protected final long lowerPart;
/** The memoized value returned by toString(). */
- private String toString;
+ private transient String toString;
//
--------------------------------------------------------------------------------------------
diff --git a/flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java
b/flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java
index 93def48a28d..65bd6b22093 100644
--- a/flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java
+++ b/flink-core/src/test/java/org/apache/flink/util/AbstractIDTest.java
@@ -22,7 +22,12 @@
import org.junit.Test;
+import java.io.InputStream;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
/**
@@ -101,6 +106,35 @@ public void testCompare() throws Exception {
assertCompare(id8, id10, -1);
}
+ /**
+ * FLINK-10412 marks the {@link AbstractID#toString} field as
transient. This tests ensures
+ * that {@link AbstractID} which have been serialized with the toString
field can still
+ * be deserialized. For that purpose the files
abstractID-with-toString-field and
+ * abstractID-with-toString-field-set have been created with the
serialized data.
+ */
+ @Test
+ public void testOldAbstractIDDeserialization() throws Exception {
+ final long lowerPart = 42L;
+ final long upperPart = 1337L;
+ final AbstractID expectedAbstractId = new AbstractID(lowerPart,
upperPart);
+
+ final String resourceName1 = "abstractID-with-toString-field";
+ try (final InputStream resourceAsStream =
getClass().getClassLoader().getResourceAsStream(resourceName1)) {
+ final AbstractID deserializedAbstractId =
InstantiationUtil.deserializeObject(
+ resourceAsStream,
+ getClass().getClassLoader());
+ assertThat(deserializedAbstractId,
is(equalTo(expectedAbstractId)));
+ }
+
+ final String resourceName2 =
"abstractID-with-toString-field-set";
+ try (final InputStream resourceAsStream =
getClass().getClassLoader().getResourceAsStream(resourceName2)) {
+ final AbstractID deserializedAbstractId =
InstantiationUtil.deserializeObject(
+ resourceAsStream,
+ getClass().getClassLoader());
+ assertThat(deserializedAbstractId,
is(equalTo(expectedAbstractId)));
+ }
+ }
+
private static void assertCompare(AbstractID a, AbstractID b, int
signum) {
int cmpAB = a.compareTo(b);
int cmpBA = b.compareTo(a);
diff --git a/flink-core/src/test/resources/abstractID-with-toString-field
b/flink-core/src/test/resources/abstractID-with-toString-field
new file mode 100644
index 00000000000..92564b487ce
Binary files /dev/null and
b/flink-core/src/test/resources/abstractID-with-toString-field differ
diff --git a/flink-core/src/test/resources/abstractID-with-toString-field-set
b/flink-core/src/test/resources/abstractID-with-toString-field-set
new file mode 100644
index 00000000000..bdf9b81b33d
Binary files /dev/null and
b/flink-core/src/test/resources/abstractID-with-toString-field-set differ
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> toString field in AbstractID should be transient to avoid been serialized
> -------------------------------------------------------------------------
>
> Key: FLINK-10412
> URL: https://issues.apache.org/jira/browse/FLINK-10412
> Project: Flink
> Issue Type: Bug
> Components: Distributed Coordination
> Affects Versions: 1.7.0
> Reporter: Zhu Zhu
> Assignee: vinoyang
> Priority: Major
> Labels: deploy,deployment, pull-request-available, serialization
> Fix For: 1.7.0
>
>
> The toString field in AbstractID will be serialized currently, which makes
> RPC messages body like InputChannelDeploymentDescriptor and PartitionInfo
> larger (50%+).
> It adds more pressure to JM memory especially in large scale job scheduling
> (10000x10000 ALL-to-ALL connection).
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)