Peter Toth created SPARK-62422:
----------------------------------

             Summary: BloomFilter.readFrom(InputStream) reads past the end of 
the filter
                 Key: SPARK-62422
                 URL: https://issues.apache.org/jira/browse/SPARK-62422
             Project: Spark
          Issue Type: Bug
          Components: Spark Core
    Affects Versions: 5.0.0
            Reporter: Peter Toth


{{BloomFilter.readFrom(InputStream)}} reads past the end of the filter. It 
wraps the caller's stream in a {{BufferedInputStream}} to peek at the version 
number, and reads the filter through that wrapper. The wrapper reads ahead, by 
up to 8 KiB, and is then dropped. So the bytes after the filter are lost to the 
caller.

For example, two filters written one after the other to one stream cannot be 
read back with two calls of {{readFrom}} on it. After the first call, 
{{available()}} is 0. The second call fails with 
{{java.nio.BufferUnderflowException}}. An input shorter than 4 bytes fails with 
the same exception instead of an {{IOException}}.

This came with SPARK-47547. Reading the version on the caller's stream, for 
example through a {{PushbackInputStream}}, avoids both.




--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to