stevedlawrence commented on a change in pull request #641:
URL: https://github.com/apache/daffodil/pull/641#discussion_r714050647
##########
File path:
daffodil-core/src/main/scala/org/apache/daffodil/compiler/Compiler.scala
##########
@@ -283,7 +284,31 @@ class Compiler private (var validateDFDLSchemas: Boolean,
def reload(savedParser: java.nio.channels.ReadableByteChannel):
DFDL.DataProcessor = {
try {
- val objInput = new ObjectInputStream(new
GZIPInputStream(Channels.newInputStream(savedParser))) {
+ val is = Channels.newInputStream(savedParser)
+
+ // Read the magic number and version information for this saved parser
+ // directly from the input stream. That information is not compressed or
+ // serialized
+ val magicNumber = "DAFFODIL "
+ magicNumber.foreach { c =>
+ if (is.read() != c.toInt) throw new InvalidParserException("The saved
parser is only compatible with an older version of Daffodil")
+ }
+
+ val sb = new StringBuilder()
+ var byte: Int = -1
+ while ({ byte = is.read(); byte > 0 }) {
+ sb.append(byte.toChar)
+ }
+ if (byte == -1) {
+ throw new InvalidParserException("The saved parser file is not the
correct format")
Review comment:
Ok, I've used "corrupted" and cleaned up the other error messages to
improve consistency
--
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]