Skip to content

Commit

Permalink
Remove unused code and clean-up the surrounding area as it is distrac…
Browse files Browse the repository at this point in the history
…ting from trying to fix the root cause of bug 58230.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1695541 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Aug 12, 2015
1 parent bb78819 commit beb7fe1
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 81 deletions.
45 changes: 9 additions & 36 deletions java/org/apache/catalina/connector/InputBuffer.java
Expand Up @@ -315,16 +315,10 @@ boolean isBlocking() {
/** /**
* Reads new bytes in the byte chunk. * Reads new bytes in the byte chunk.
* *
* @param cbuf Byte buffer to be written to the response
* @param off Offset
* @param len Length
*
* @throws IOException An underlying IOException occurred * @throws IOException An underlying IOException occurred
*/ */
@Override @Override
public int realReadBytes(byte cbuf[], int off, int len) public int realReadBytes() throws IOException {
throws IOException {

if (closed) { if (closed) {
return -1; return -1;
} }
Expand All @@ -339,13 +333,10 @@ public int realReadBytes(byte cbuf[], int off, int len)
int result = coyoteRequest.doRead(bb); int result = coyoteRequest.doRead(bb);


return result; return result;

} }




public int readByte() public int readByte() throws IOException {
throws IOException {

if (closed) { if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed")); throw new IOException(sm.getString("inputBuffer.streamClosed"));
} }
Expand All @@ -354,9 +345,7 @@ public int readByte()
} }




public int read(byte[] b, int off, int len) public int read(byte[] b, int off, int len) throws IOException {
throws IOException {

if (closed) { if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed")); throw new IOException(sm.getString("inputBuffer.streamClosed"));
} }
Expand All @@ -375,8 +364,7 @@ public int read(byte[] b, int off, int len)
* mark is lost. * mark is lost.
*/ */
@Override @Override
public void realWriteChars(char c[], int off, int len) public void realWriteChars(char c[], int off, int len) throws IOException {
throws IOException {
markPos = -1; markPos = -1;
cb.setOffset(0); cb.setOffset(0);
cb.setEnd(0); cb.setEnd(0);
Expand All @@ -389,17 +377,15 @@ public void setEncoding(String s) {




@Override @Override
public int realReadChars(char cbuf[], int off, int len) public int realReadChars() throws IOException {
throws IOException {

if (!gotEnc) { if (!gotEnc) {
setConverter(); setConverter();
} }


boolean eof = false; boolean eof = false;


if (bb.getLength() <= 0) { if (bb.getLength() <= 0) {
int nRead = realReadBytes(bb.getBytes(), 0, bb.getBytes().length); int nRead = realReadBytes();
if (nRead < 0) { if (nRead < 0) {
eof = true; eof = true;
} }
Expand Down Expand Up @@ -467,10 +453,7 @@ public int read(char[] cbuf, int off, int len)




@Override @Override
public long skip(long n) public long skip(long n) throws IOException {
throws IOException {


if (closed) { if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed")); throw new IOException(sm.getString("inputBuffer.streamClosed"));
} }
Expand All @@ -487,28 +470,18 @@ public long skip(long n)
} else { } else {
nRead += cb.getLength(); nRead += cb.getLength();
cb.setOffset(cb.getEnd()); cb.setOffset(cb.getEnd());
int toRead = 0; int nb = realReadChars();
if (cb.getChars().length < (n - nRead)) {
toRead = cb.getChars().length;
} else {
toRead = (int) (n - nRead);
}
int nb = realReadChars(cb.getChars(), 0, toRead);
if (nb < 0) { if (nb < 0) {
break; break;
} }
} }
} }

return nRead; return nRead;

} }




@Override @Override
public boolean ready() public boolean ready() throws IOException {
throws IOException {

if (closed) { if (closed) {
throw new IOException(sm.getString("inputBuffer.streamClosed")); throw new IOException(sm.getString("inputBuffer.streamClosed"));
} }
Expand Down
43 changes: 18 additions & 25 deletions java/org/apache/tomcat/util/buf/ByteChunk.java
Expand Up @@ -75,12 +75,13 @@ public final class ByteChunk implements Cloneable, Serializable {
*/ */
public static interface ByteInputChannel { public static interface ByteInputChannel {
/** /**
* Read new bytes ( usually the internal conversion buffer ). * Read new bytes.
* The implementation is allowed to ignore the parameters, *
* and mutate the chunk if it wishes to implement its own buffering. * @return The number of bytes read
*
* @throws IOException If an I/O occurs while reading the bytes
*/ */
public int realReadBytes(byte cbuf[], int off, int len) public int realReadBytes() throws IOException;
throws IOException;
} }


/** Same as java.nio.channel.WrittableByteChannel. /** Same as java.nio.channel.WrittableByteChannel.
Expand Down Expand Up @@ -353,59 +354,51 @@ public void append( byte src[], int off, int len )


// -------------------- Removing data from the buffer -------------------- // -------------------- Removing data from the buffer --------------------


public int substract() public int substract() throws IOException {
throws IOException {

if ((end - start) == 0) { if ((end - start) == 0) {
if (in == null) { if (in == null) {
return -1; return -1;
} }
int n = in.realReadBytes( buff, 0, buff.length ); int n = in.realReadBytes();
if (n < 0) { if (n < 0) {
return -1; return -1;
} }
} }

return (buff[start++] & 0xFF); return (buff[start++] & 0xFF);

} }


public byte substractB()
throws IOException {


public byte substractB() throws IOException {
if ((end - start) == 0) { if ((end - start) == 0) {
if (in == null) if (in == null) {
return -1; return -1;
int n = in.realReadBytes( buff, 0, buff.length ); }
if (n < 0) int n = in.realReadBytes();
if (n < 0) {
return -1; return -1;
}
} }

return buff[start++];
return (buff[start++]);

} }


public int substract( byte src[], int off, int len )
throws IOException {


public int substract(byte dest[], int off, int len ) throws IOException {
if ((end - start) == 0) { if ((end - start) == 0) {
if (in == null) { if (in == null) {
return -1; return -1;
} }
int n = in.realReadBytes( buff, 0, buff.length ); int n = in.realReadBytes();
if (n < 0) { if (n < 0) {
return -1; return -1;
} }
} }

int n = len; int n = len;
if (len > getLength()) { if (len > getLength()) {
n = getLength(); n = getLength();
} }
System.arraycopy(buff, start, src, off, n); System.arraycopy(buff, start, dest, off, n);
start += n; start += n;
return n; return n;

} }




Expand Down
32 changes: 12 additions & 20 deletions java/org/apache/tomcat/util/buf/CharChunk.java
Expand Up @@ -37,12 +37,13 @@ public final class CharChunk implements Cloneable, Serializable, CharSequence {
// Input interface, used when the buffer is emptied. // Input interface, used when the buffer is emptied.
public static interface CharInputChannel { public static interface CharInputChannel {
/** /**
* Read new bytes ( usually the internal conversion buffer ). * Read new characters.
* The implementation is allowed to ignore the parameters, *
* and mutate the chunk if it wishes to implement its own buffering. * @return The number of characters read
*
* @throws IOException If an I/O error occurs reading the characters
*/ */
public int realReadChars(char cbuf[], int off, int len) public int realReadChars() throws IOException;
throws IOException;
} }
/** /**
* When we need more space we'll either * When we need more space we'll either
Expand Down Expand Up @@ -341,31 +342,25 @@ public void append(String s, int off, int len) throws IOException {


// -------------------- Removing data from the buffer -------------------- // -------------------- Removing data from the buffer --------------------


public int substract() public int substract() throws IOException {
throws IOException {

if ((end - start) == 0) { if ((end - start) == 0) {
if (in == null) { if (in == null) {
return -1; return -1;
} }
int n = in.realReadChars(buff, end, buff.length - end); int n = in.realReadChars();
if (n < 0) { if (n < 0) {
return -1; return -1;
} }
} }

return (buff[start++]); return (buff[start++]);

} }


public int substract( char src[], int off, int len ) public int substract(char dest[], int off, int len) throws IOException {
throws IOException {

if ((end - start) == 0) { if ((end - start) == 0) {
if (in == null) { if (in == null) {
return -1; return -1;
} }
int n = in.realReadChars( buff, end, buff.length - end); int n = in.realReadChars();
if (n < 0) { if (n < 0) {
return -1; return -1;
} }
Expand All @@ -375,16 +370,13 @@ public int substract( char src[], int off, int len )
if (len > getLength()) { if (len > getLength()) {
n = getLength(); n = getLength();
} }
System.arraycopy(buff, start, src, off, n); System.arraycopy(buff, start, dest, off, n);
start += n; start += n;
return n; return n;

} }




public void flushBuffer() public void flushBuffer() throws IOException {
throws IOException
{
//assert out!=null //assert out!=null
if( out==null ) { if( out==null ) {
throw new IOException( "Buffer overflow, no sink " + limit + " " + throw new IOException( "Buffer overflow, no sink " + limit + " " +
Expand Down

0 comments on commit beb7fe1

Please sign in to comment.