equal
deleted
inserted
replaced
236 pos * 2 : MAX_BUFFER_SIZE; |
236 pos * 2 : MAX_BUFFER_SIZE; |
237 if (nsz > marklimit) |
237 if (nsz > marklimit) |
238 nsz = marklimit; |
238 nsz = marklimit; |
239 byte[] nbuf = new byte[nsz]; |
239 byte[] nbuf = new byte[nsz]; |
240 System.arraycopy(buffer, 0, nbuf, 0, pos); |
240 System.arraycopy(buffer, 0, nbuf, 0, pos); |
241 if (!U.compareAndSetObject(this, BUF_OFFSET, buffer, nbuf)) { |
241 if (!U.compareAndSetReference(this, BUF_OFFSET, buffer, nbuf)) { |
242 // Can't replace buf if there was an async close. |
242 // Can't replace buf if there was an async close. |
243 // Note: This would need to be changed if fill() |
243 // Note: This would need to be changed if fill() |
244 // is ever made accessible to multiple threads. |
244 // is ever made accessible to multiple threads. |
245 // But for now, the only way CAS can fail is via close. |
245 // But for now, the only way CAS can fail is via close. |
246 // assert buf == null; |
246 // assert buf == null; |
480 * @exception IOException if an I/O error occurs. |
480 * @exception IOException if an I/O error occurs. |
481 */ |
481 */ |
482 public void close() throws IOException { |
482 public void close() throws IOException { |
483 byte[] buffer; |
483 byte[] buffer; |
484 while ( (buffer = buf) != null) { |
484 while ( (buffer = buf) != null) { |
485 if (U.compareAndSetObject(this, BUF_OFFSET, buffer, null)) { |
485 if (U.compareAndSetReference(this, BUF_OFFSET, buffer, null)) { |
486 InputStream input = in; |
486 InputStream input = in; |
487 in = null; |
487 in = null; |
488 if (input != null) |
488 if (input != null) |
489 input.close(); |
489 input.close(); |
490 return; |
490 return; |