Github user bodewig commented on a diff in the pull request:
https://github.com/apache/commons-compress/pull/21#discussion_r112838584
--- Diff:
src/main/java/org/apache/commons/compress/archivers/zip/ZipFile.java ---
@@ -1111,14 +1122,11 @@ public int read() throws IOException {
}
return -1;
}
- synchronized (archive) {
- archive.position(loc++);
- int read = read(1);
- if (read < 0) {
- return read;
- }
- return buffer.get() & 0xff;
+ int read = read(loc++, 1);
+ if (read < 0) {
--- End diff --
I think it depends on what we think `synchronized` is supposed to protect
against.
As it stands the `synchronized` block also protected concurrent reads from
the same `BoundedInputStream` from overwriting their results (protecting `loc`
and `buffer` not just the file position).
If we want to keep that level of protection the changes are not going to
work. If we say each input stream returned by `getInputStream` can only be used
by a single thread, then I think it is fine to keep the increment outside of
the block and only synchronise the code that protects the interaction between
different streams.
---
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]