[ http://issues.apache.org/jira/browse/DERBY-1417?page=comments#action_12425048 ] Kristian Waagan commented on DERBY-1417: ----------------------------------------
Thanks for looking at the patch, Rick :) I added the test case mostly to demonstrate the expected behavior. a) The user should never trip across this at all. If it is thrown, it must be because of a programming error in Derby. Currently, the byte arrays passed in are read from a user/application stream, and the bytes are counted as they are read. b) The user would see something ugly... For the non-debug version, replace the linenumbers with "Unknown Source". The error is constructed. 1) testSetClobLengthless(org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest)java.lang.IllegalArgumentException: Length cannot be negative: -37 at org.apache.derby.client.am.ByteArrayCombinerStream.<init>(ByteArrayCombinerStream.java:78) at org.apache.derby.client.am.Lob.materializeStream(Lob.java:164) at org.apache.derby.client.am.Clob.materializeStream(Clob.java:833) at org.apache.derby.client.am.Clob.length(Clob.java:216) at org.apache.derby.client.net.NetStatementRequest.computeProtocolTypesAndLengths(NetStatementRequest.java:1232) at org.apache.derby.client.net.NetStatementRequest.buildSQLDTAcommandData(NetStatementRequest.java:520) at org.apache.derby.client.net.NetStatementRequest.writeExecute(NetStatementRequest.java:139) at org.apache.derby.client.net.NetPreparedStatement.writeExecute_(NetPreparedStatement.java:171) at org.apache.derby.client.am.PreparedStatement.writeExecute(PreparedStatement.java:1543) at org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:1789) at org.apache.derby.client.am.PreparedStatement.executeX(PreparedStatement.java:1347) at org.apache.derby.client.am.PreparedStatement.execute(PreparedStatement.java:1332) at org.apache.derbyTesting.functionTests.tests.jdbc4.PreparedStatementTest.testSetClobLengthless(PreparedStatementTest.java:375) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at org.apache.derbyTesting.functionTests.util.BaseTestCase.runBare(Unknown Source) I realize this does not look good, but it should not happen. I don't feel like making these two exceptions checked, or just ignore the error conditions (as the previous implementation did). Does anyone have opinions? Are there guidelines to follow? Thanks, > Add new, lengthless overloads to the streaming api > -------------------------------------------------- > > Key: DERBY-1417 > URL: http://issues.apache.org/jira/browse/DERBY-1417 > Project: Derby > Issue Type: New Feature > Components: JDBC > Affects Versions: 10.2.0.0 > Reporter: Rick Hillegas > Assigned To: Kristian Waagan > Fix For: 10.2.0.0 > > Attachments: derby-1417-01-castsInTests.diff, > derby-1417-1a-notImplemented.diff, derby-1417-1a-notImplemented.stat, > derby-1417-2a-rstest-refactor.diff, derby-1417-3a-embimpl-and-tests.diff, > derby-1417-3a-embimpl-and-tests.stat, derby-1417-3b-embimpl-and-tests.diff, > derby-1417-3b-embimpl-and-tests.stat, derby-1417-4a-disable-psTestsDnc.diff, > derby-1417-5a-brokered.diff, derby-1417-5a-brokered.stat, > derby-1417-6a-clientimpl.diff, derby-1417-6a-clientimpl.stat, > derby-1417-6b-clientimpl.diff, derby-1417-6c-clientimpl.diff, > derby-1417-6d-clientimpl.diff, derby-1417-7a-clientborderfix.diff, > derby-1417-7a-clientborderfix.stat > > > The JDBC4 Expert Group has approved a new set of overloads for the streaming > methods. These overloads do not take a length argument. Here are the new > overloads: > PreparedStatement.setAsciiStream(int parameterIndex, java.io.InputStream x) > PreparedStatement.setBinaryStream(int parameterIndex, java.io.InputStream x) > PreparedStatement.setCharacterStream(int parameterIndex, java.io.Reader > reader) > PreparedStatement.setNCharacterStream(int parameterIndex, java.io.Reader > reader) > PreparedStatement.setBlob(int parameterIndex, java.io.InputStream inputStream) > PreparedStatement.setClob(int parameterIndex, java.io.Reader reader) > PreparedStatement.setNClob(int parameterIndex, java.io.Reader reader) > CallableStatement.setAsciiStream(java.lang.String parameterName, > java.io.InputStream x) > CallableStatement.setBinaryStream(java.lang.String parameterName, > java.io.InputStream x) > CallableStatement.setCharacterStream(java.lang.String parameterName, > java.io.Reader reader) > CallableStatement.setNCharacterStream(java.lang.String parameterName, > java.io.Reader reader) > CallableStatement.setBlob(java.lang.String parameterName, java.io.InputStream > inputStream) > CallableStatement.setClob(java.lang.String parameterName, java.io.Reader > reader) > CallableStatement.setNClob(java.lang.String parameterName, java.io.Reader > reader) > ResultSet.updateAsciiStream(int columnIndex, java.io.InputStream x) > ResultSet.updateAsciiStream(java.lang.String columnLabel, java.io.InputStream > x) > ResultSet.updateBinaryStream(int columnIndex, java.io.InputStream x) > ResultSet.updateBinaryStream(java.lang.String columnLabel, > java.io.InputStream x, int length) > ResultSet.updateCharacterStream(int columnIndex, java.io.Reader x) > ResultSet.updateCharacterStream(java.lang.String columnLabel, java.io.Reader > x) > ResultSet.updateNCharacterStream(int columnIndex, java.io.Reader x) > ResultSet.updateNCharacterStream(java.lang.String columnLabel, java.io.Reader > x) > ResultSet.updateBlob(int columnIndex, java.io.InputStream inputStream) > ResultSet.updateBlob(java.lang.String columnLabel, java.io.InputStream > inputStream) > ResultSet.updateClob(int columnIndex, java.io.Reader reader) > ResultSet.updateClob(java.lang.String columnLabel, java.io.Reader reader) > ResultSet.updateNClob(int columnIndex, java.io.Reader reader) > ResultSet.updateNClob(java.lang.String columnLabel, java.io.Reader reader) > We should add these new overloads soon so that the build will not break when > this methods turn up in a published Mustang build. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira