Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/3792#discussion_r22262724
--- Diff:
network/common/src/main/java/org/apache/spark/network/util/JavaUtils.java ---
@@ -41,6 +41,34 @@
public class JavaUtils {
private static final Logger logger =
LoggerFactory.getLogger(JavaUtils.class);
+ /** Deserialize a byte array using Java serialization. */
+ public static <T> T deserialize(byte[] bytes) {
+ try {
+ ObjectInputStream is = new ObjectInputStream(new
ByteArrayInputStream(bytes));
+ Object out = is.readObject();
+ is.close();
+ return (T) out;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Could not deserialize object", e);
--- End diff --
Yeah pretty standard formulation. Nit suggestion: don't throw general
`RuntimeException` but something marginally more specific like
`IllegalStateException`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]