[
https://issues.apache.org/jira/browse/HDFS-7494?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14244802#comment-14244802
]
Colin Patrick McCabe commented on HDFS-7494:
--------------------------------------------
Hi [~tedyu],
We cannot take the stream lock in pread without introducing some big
performance regressions. See HDFS-6735 for why we stopped taking the lock
here... basically, it's because we wanted {{pread()}} to be able to proceed
independently of {{read()}}.
Let's make this an {{AtomicBoolean}} instead. Then, we can just check it with
{{AtomicBoolean#get}}. In {{DFSInputStream#close}}, we can do
{{AtomicBoolean#compareAndSet}} to ensure close happens only once, even if
there are concurrent calls.
> Checking of closed in DFSInputStream#pread() should be protected by
> synchronization
> -----------------------------------------------------------------------------------
>
> Key: HDFS-7494
> URL: https://issues.apache.org/jira/browse/HDFS-7494
> Project: Hadoop HDFS
> Issue Type: Bug
> Reporter: Ted Yu
> Priority: Minor
>
> {code}
> private int pread(long position, byte[] buffer, int offset, int length)
> throws IOException {
> // sanity checks
> dfsClient.checkOpen();
> if (closed) {
> {code}
> Checking of closed should be protected by holding lock on
> "DFSInputStream.this"
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)