[#5059] Deprecate method with typo and introduce a new one without typo

Motivation:

There is a spelling error in FileRegion.transfered() as it should be transferred().

Modifications:

Deprecate old method and add a new one.

Result:

Fix typo and can remove the old method later.
This commit is contained in:
Norman Maurer 2016-03-30 11:27:12 +02:00
parent 105df33d8d
commit f46cfbc590
8 changed files with 29 additions and 10 deletions

View File

@ -76,6 +76,11 @@ public class HttpResponseEncoderTest {
return 0;
}
@Override
public long transferred() {
return 0;
}
@Override
public long count() {
return INTEGER_OVERLFLOW;

View File

@ -364,7 +364,7 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
private boolean writeFileRegion(
ChannelOutboundBuffer in, DefaultFileRegion region, int writeSpinCount) throws Exception {
final long regionCount = region.count();
if (region.transfered() >= regionCount) {
if (region.transferred() >= regionCount) {
in.remove();
return true;
}
@ -374,7 +374,7 @@ public abstract class AbstractEpollStreamChannel extends AbstractEpollChannel im
long flushedAmount = 0;
for (int i = writeSpinCount - 1; i >= 0; i--) {
final long offset = region.transfered();
final long offset = region.transferred();
final long localFlushedAmount =
Native.sendfile(fd().intValue(), region, baseOffset, offset, regionCount - offset);
if (localFlushedAmount == 0) {

View File

@ -114,11 +114,17 @@ public class DefaultFileRegion extends AbstractReferenceCounted implements FileR
return count;
}
@Deprecated
@Override
public long transfered() {
return transfered;
}
@Override
public long transferred() {
return transfered;
}
@Override
public long transferTo(WritableByteChannel target, long position) throws IOException {
long count = this.count - position;

View File

@ -60,10 +60,18 @@ public interface FileRegion extends ReferenceCounted {
long position();
/**
* Return the bytes which was transfered already
* Returns the bytes which was transfered already.
*
* @deprecated Use {@link #transferred()} instead.
*/
@Deprecated
long transfered();
/**
* Returns the bytes which was transfered already.
*/
long transferred();
/**
* Returns the number of bytes to transfer.
*/

View File

@ -201,7 +201,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
}
} else if (msg instanceof FileRegion) {
FileRegion region = (FileRegion) msg;
boolean done = region.transfered() >= region.count();
boolean done = region.transferred() >= region.count();
if (!done) {
long flushedAmount = 0;
@ -217,7 +217,7 @@ public abstract class AbstractNioByteChannel extends AbstractNioChannel {
}
flushedAmount += localFlushedAmount;
if (region.transfered() >= region.count()) {
if (region.transferred() >= region.count()) {
done = true;
break;
}

View File

@ -208,9 +208,9 @@ public abstract class AbstractOioByteChannel extends AbstractOioChannel {
in.remove();
} else if (msg instanceof FileRegion) {
FileRegion region = (FileRegion) msg;
long transfered = region.transfered();
long transferred = region.transferred();
doWriteFileRegion(region);
in.progress(region.transfered() - transfered);
in.progress(region.transferred() - transferred);
in.remove();
} else {
in.remove(new UnsupportedOperationException(

View File

@ -144,9 +144,9 @@ public abstract class OioByteStreamChannel extends AbstractOioByteChannel {
}
private static void checkEOF(FileRegion region) throws IOException {
if (region.transfered() < region.count()) {
if (region.transferred() < region.count()) {
throw new EOFException("Expected to be able to write " + region.count() + " bytes, " +
"but only wrote " + region.transfered());
"but only wrote " + region.transferred());
}
}

View File

@ -253,7 +253,7 @@ public class NioSocketChannel extends AbstractNioByteChannel implements io.netty
@Override
protected long doWriteFileRegion(FileRegion region) throws Exception {
final long position = region.transfered();
final long position = region.transferred();
return region.transferTo(javaChannel(), position);
}