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.
*
* @param cbuf Byte buffer to be written to the response
* @param off Offset
* @param len Length
*
* @throws IOException An underlying IOException occurred
*/
@Override
public int realReadBytes(byte cbuf[], int off, int len)
throws IOException {

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

return result;

}


public int readByte()
throws IOException {

public int readByte() throws IOException {
if (closed) {
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)
throws IOException {

public int read(byte[] b, int off, int len) throws IOException {
if (closed) {
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.
*/
@Override
public void realWriteChars(char c[], int off, int len)
throws IOException {
public void realWriteChars(char c[], int off, int len) throws IOException {
markPos = -1;
cb.setOffset(0);
cb.setEnd(0);
Expand All @@ -389,17 +377,15 @@ public void setEncoding(String s) {


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

public int realReadChars() throws IOException {
if (!gotEnc) {
setConverter();
}

boolean eof = false;

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


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


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

return nRead;

}


@Override
public boolean ready()
throws IOException {

public boolean ready() throws IOException {
if (closed) {
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 {
/**
* Read new bytes ( usually the internal conversion buffer ).
* The implementation is allowed to ignore the parameters,
* and mutate the chunk if it wishes to implement its own buffering.
* Read new bytes.
*
* @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)
throws IOException;
public int realReadBytes() throws IOException;
}

/** 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 --------------------

public int substract()
throws IOException {

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

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

}

public byte substractB()
throws IOException {

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

int n = len;
if (len > getLength()) {
n = getLength();
}
System.arraycopy(buff, start, src, off, n);
System.arraycopy(buff, start, dest, off, n);
start += 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.
public static interface CharInputChannel {
/**
* Read new bytes ( usually the internal conversion buffer ).
* The implementation is allowed to ignore the parameters,
* and mutate the chunk if it wishes to implement its own buffering.
* Read new characters.
*
* @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)
throws IOException;
public int realReadChars() throws IOException;
}
/**
* 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 --------------------

public int substract()
throws IOException {

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

return (buff[start++]);

}

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

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

}


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

0 comments on commit beb7fe1

Please sign in to comment.