public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
        // sanity Check
        checkIndex(columnIndex);
        // make sure the cursor is on a valid row
        checkCursor();


        if (isString(RowSetMD.getColumnType(columnIndex)) == false &&
        isBinary(RowSetMD.getColumnType(columnIndex)) == false) {
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.dtypemismt").toString());
        }

        byte buf[] = new byte[length];
        try {
            int charsRead = 0;
            do {
                charsRead += x.read(buf, charsRead, length - charsRead);
            } while (charsRead != length);
            //Changed the condition check to check for length instead of -1
        } catch (IOException ex) {
            throw new SQLException(resBundle.handleGetObject("cachedrowsetimpl.asciistream").toString());
        }
        String str = new String(buf);

        getCurrentRow().setColumnObject(columnIndex, str);

    }
Sets the designated column in either the current row or the insert
row of this <code>CachedRowSetImpl</code> object with the given
ASCII stream value.
<P>
This method updates a column value in either the current row or
the insert row of this rowset, but it does not update the
database.  If the cursor is on a row in the rowset, the
method {@link #updateRow} must be called to update the database.
If the cursor is on the insert row, the method {@link #insertRow}
must be called, which will insert the new row into both this rowset
and the database. Both of these methods must be called before the
cursor moves to another row.

@param columnIndex the first column is <code>1</code>, the second
       is <code>2</code>, and so on; must be <code>1</code> or larger
       and equal to or less than the number of columns in this rowset
@param x the new column value
@param length the number of one-byte ASCII characters in the stream
@throws SQLException if this method is invoked
src/main/java/org/replicadb/rowset/sun/rowset/CachedRowSetImpl.java