Skip to content

Commit

Permalink
8294361: Cleanup usages of StringBuffer in SQLOutputImpl
Browse files Browse the repository at this point in the history
Reviewed-by: rriggs, lancea
  • Loading branch information
Andrey Turbanov committed Sep 27, 2022
1 parent 1abf971 commit 3419363
Showing 1 changed file with 21 additions and 36 deletions.
Expand Up @@ -321,24 +321,20 @@ public void writeTimestamp(java.sql.Timestamp x) throws SQLException {
* use by a <code>SQLData</code> object attempting to write the attribute
* values of a UDT to the database.
*/
@SuppressWarnings("unchecked")
public void writeCharacterStream(java.io.Reader x) throws SQLException {
BufferedReader bufReader = new BufferedReader(x);
try {
int i;
while( (i = bufReader.read()) != -1 ) {
BufferedReader bufReader = new BufferedReader(x);
try {
int i;
while ((i = bufReader.read()) != -1) {
char ch = (char)i;
StringBuffer strBuf = new StringBuffer();
strBuf.append(ch);

String str = new String(strBuf);
String strLine = bufReader.readLine();

writeString(str.concat(strLine));
}
} catch(IOException ioe) {
writeString(ch + strLine);
}
} catch (IOException ioe) {

}
}
}

/**
Expand All @@ -351,23 +347,17 @@ public void writeCharacterStream(java.io.Reader x) throws SQLException {
* use by a <code>SQLData</code> object attempting to write the attribute
* values of a UDT to the database.
*/
@SuppressWarnings("unchecked")
public void writeAsciiStream(java.io.InputStream x) throws SQLException {
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
try {
int i;
while( (i=bufReader.read()) != -1 ) {
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
try {
int i;
while ((i = bufReader.read()) != -1) {
char ch = (char)i;

StringBuffer strBuf = new StringBuffer();
strBuf.append(ch);

String str = new String(strBuf);
String strLine = bufReader.readLine();

writeString(str.concat(strLine));
writeString(ch + strLine);
}
}catch(IOException ioe) {
} catch (IOException ioe) {
throw new SQLException(ioe.getMessage());
}
}
Expand All @@ -381,23 +371,18 @@ public void writeAsciiStream(java.io.InputStream x) throws SQLException {
* use by a <code>SQLData</code> object attempting to write the attribute
* values of a UDT to the database.
*/
@SuppressWarnings("unchecked")
public void writeBinaryStream(java.io.InputStream x) throws SQLException {
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
try {
int i;
while( (i=bufReader.read()) != -1 ) {
BufferedReader bufReader = new BufferedReader(new InputStreamReader(x));
try {
int i;
while ((i = bufReader.read()) != -1) {
char ch = (char)i;

StringBuffer strBuf = new StringBuffer();
strBuf.append(ch);

String str = new String(strBuf);
String strLine = bufReader.readLine();

writeString(str.concat(strLine));
}
} catch(IOException ioe) {
writeString(ch + strLine);
}
} catch (IOException ioe) {
throw new SQLException(ioe.getMessage());
}
}
Expand Down

1 comment on commit 3419363

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.