You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@daffodil.apache.org by GitBox <gi...@apache.org> on 2019/01/04 18:53:45 UTC

[GitHub] stevedlawrence commented on a change in pull request #161: Make the JAPI/SAPI DataProcessors serializable

stevedlawrence commented on a change in pull request #161: Make the JAPI/SAPI DataProcessors serializable
URL: https://github.com/apache/incubator-daffodil/pull/161#discussion_r245387563
 
 

 ##########
 File path: daffodil-japi/src/test/java/org/apache/daffodil/example/TestJavaAPI.java
 ##########
 @@ -59,8 +61,34 @@
         }
     }
 
+    public DataProcessor reserializeDataProcessor(DataProcessor dp) throws IOException, ClassNotFoundException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+        oos.writeObject(dp);
+        oos.close();
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+        ObjectInputStream ois = new ObjectInputStream(bais) {
+            /**
 
 Review comment:
   Really, only the ``with Serialize`` stuff is all that is needed to get things to work.
   
   But in addition to those changes, I made it so that all the JAPI and SAPI tests create a DataProcessor as normal but then also serialize and deserialize the DataProcessor, just to give some confidence that I made everything Serializable that needs to be. That's what this reserializeDataPrcoessor function does. It takes the DataProcessor that the test creates, seralizes it, deserializes it, and returns it. Then the tests use that one for the rest of the test. So this is purely used for testing within this file--no extra maintenence burden for us or users of Daffodil. Something like Spark wouldn't need this logic. They can just create a new ObjectInputStream like one would normally do.
   
   Unfortunately, SBT closed that bug without fixing it. I think they just claim this is how SBT is expected to work so this is required. So I don't think it's ever going to be fixed.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services