commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kvr000 <...@git.apache.org>
Subject [GitHub] commons-compress pull request #21: COMPRESS-388: Fix concurrent reads perfor...
Date Sun, 23 Apr 2017 16:37:57 GMT
Github user kvr000 commented on a diff in the pull request:

    https://github.com/apache/commons-compress/pull/21#discussion_r112838864
  
    --- 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 --
    
    Correct, bodewig. Additionally, note that in these terms the original implementation wasn't
thread-safe - in the byte[] read method the loc incrementing is outside the synchronized too.
    
    Anyway, there are two options - either make the full methods synchronized (the single
stream would hardly ever be accessed concurrently so keeping smaller scope won't make any
difference).
    
    Or, better option would be to keep this implementation unsynchronized as it's wrapped
into another decompressing stream anyway and this one already has to be synchronized. The
only exception is STORED compression method where we would have to wrap into synchronized
proxy.



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message