equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
366 this.in = in; |
366 this.in = in; |
367 } |
367 } |
368 |
368 |
369 @Override |
369 @Override |
370 public int read(ByteBuffer dst) throws IOException { |
370 public int read(ByteBuffer dst) throws IOException { |
|
371 if (!isOpen()) { |
|
372 throw new ClosedChannelException(); |
|
373 } |
|
374 |
371 int len = dst.remaining(); |
375 int len = dst.remaining(); |
372 int totalRead = 0; |
376 int totalRead = 0; |
373 int bytesRead = 0; |
377 int bytesRead = 0; |
374 synchronized (readLock) { |
378 synchronized (readLock) { |
375 while (totalRead < len) { |
379 while (totalRead < len) { |
440 this.out = out; |
444 this.out = out; |
441 } |
445 } |
442 |
446 |
443 @Override |
447 @Override |
444 public int write(ByteBuffer src) throws IOException { |
448 public int write(ByteBuffer src) throws IOException { |
|
449 if (!isOpen()) { |
|
450 throw new ClosedChannelException(); |
|
451 } |
|
452 |
445 int len = src.remaining(); |
453 int len = src.remaining(); |
446 int totalWritten = 0; |
454 int totalWritten = 0; |
447 synchronized (writeLock) { |
455 synchronized (writeLock) { |
448 while (totalWritten < len) { |
456 while (totalWritten < len) { |
449 int bytesToWrite = Math.min((len - totalWritten), |
457 int bytesToWrite = Math.min((len - totalWritten), |