[
https://issues.apache.org/jira/browse/DERBY-4315?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Rick Hillegas updated DERBY-4315:
---------------------------------
Attachment: StreamError.java
Attaching StreamError.java. This class shows another error related to the
exception processing in this part of our network driver.
The attached StreamError class raises an ArrayIndexOutOfBoundsException half
way through reading the input stream. All sorts of Exceptions could be raised
by a user-written InputStream. But the network client only looks for
IOExceptions. If the network client sees an IOException, then you get the
behavior described by this bug report: the user sees a puzzling protocol error
when there is no real protocol error. The error is in the InputStream which is
running purely on the client-side. If the InputStream raises an exeption other
than an IOException, then a protocol error does not return to the user.
Instead, the error raised by the stream percolates up to higher levels of
exception management in the client driver. However, in that case a real
protocol error follows and you see two consequences:
1) In the server log you see the following protocol error:
org.apache.derby.impl.drda.DRDAProtocolException: Execution failed because of a
Distributed Protocol Error: DRDA_Disconnect; CODPNT arg = 0; Error Code Value
= 0,DDMReader.fill(),InputStream.read(),insufficient data,*
at
org.apache.derby.impl.drda.DRDAProtocolException.newDisconnectException(DRDAProtocolException.java:325)
at
org.apache.derby.impl.drda.DRDAConnThread.markCommunicationsFailure(DRDAConnThread.java:503)
at
org.apache.derby.impl.drda.DRDAConnThread.markCommunicationsFailure(DRDAConnThread.java:472)
at org.apache.derby.impl.drda.DDMReader.fill(DDMReader.java:1965)
at
org.apache.derby.impl.drda.DDMReader.ensureALayerDataInBuffer(DDMReader.java:1684)
at
org.apache.derby.impl.drda.DDMReader.readDSSContinuationHeader(DDMReader.java:1225)
at
org.apache.derby.impl.drda.DDMReader.readLOBChunk(DDMReader.java:1122)
at
org.apache.derby.impl.drda.DDMReader.readLOBContinuationStream(DDMReader.java:1099)
at
org.apache.derby.impl.drda.StandardEXTDTAReaderInputStream.nextBuffer(StandardEXTDTAReaderInputStream.java:183)
at
org.apache.derby.impl.drda.StandardEXTDTAReaderInputStream.read(StandardEXTDTAReaderInputStream.java:116)
at java.io.FilterInputStream.read(FilterInputStream.java:116)
at
org.apache.derby.iapi.services.io.LimitInputStream.read(LimitInputStream.java:74)
at
org.apache.derby.iapi.types.RawToBinaryFormatStream.read(RawToBinaryFormatStream.java:273)
at
org.apache.derby.impl.store.raw.data.MemByteHolder.write(MemByteHolder.java:146)
at
org.apache.derby.impl.store.raw.data.RememberBytesInputStream.fillBuf(RememberBytesInputStream.java:135)
at
org.apache.derby.impl.store.raw.data.StoredPage.logColumn(StoredPage.java:6197)
at
org.apache.derby.impl.store.raw.data.StoredPage.logLongColumn(StoredPage.java:6044)
at
org.apache.derby.impl.store.raw.data.InsertOperation.writeOptionalDataToBuffer(InsertOperation.java:367)
at
org.apache.derby.impl.store.raw.data.InsertOperation.<init>(InsertOperation.java:115)
at
org.apache.derby.impl.store.raw.data.LoggableActions.actionInsert(LoggableActions.java:139)
at
org.apache.derby.impl.store.raw.data.BasePage.insertLongColumn(BasePage.java:938)
at
org.apache.derby.impl.store.raw.data.BasePage.insertAllowOverflow(BasePage.java:763)
at
org.apache.derby.impl.store.raw.data.BasePage.insert(BasePage.java:632)
at
org.apache.derby.impl.store.access.heap.HeapController.doInsert(HeapController.java:307)
at
org.apache.derby.impl.store.access.heap.HeapController.insert(HeapController.java:575)
at
org.apache.derby.impl.sql.execute.RowChangerImpl.insertRow(RowChangerImpl.java:457)
at
org.apache.derby.impl.sql.execute.InsertResultSet.normalInsertCore(InsertResultSet.java:1028)
at
org.apache.derby.impl.sql.execute.InsertResultSet.open(InsertResultSet.java:505)
at
org.apache.derby.impl.sql.GenericPreparedStatement.executeStmt(GenericPreparedStatement.java:436)
at
org.apache.derby.impl.sql.GenericPreparedStatement.execute(GenericPreparedStatement.java:317)
at
org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(EmbedStatement.java:1241)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.executeStatement(EmbedPreparedStatement.java:1686)
at
org.apache.derby.impl.jdbc.EmbedPreparedStatement.execute(EmbedPreparedStatement.java:1341)
at
org.apache.derby.impl.drda.DRDAStatement.execute(DRDAStatement.java:672)
at
org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTTobjects(DRDAConnThread.java:4316)
at
org.apache.derby.impl.drda.DRDAConnThread.parseEXCSQLSTT(DRDAConnThread.java:4133)
at
org.apache.derby.impl.drda.DRDAConnThread.processCommands(DRDAConnThread.java:1021)
at
org.apache.derby.impl.drda.DRDAConnThread.run(DRDAConnThread.java:294)
2) After that, an attempt to shutdown the server results in the following error
on the client (the next attempt to shutdown the server succeeds, however):
Fri Nov 19 09:00:38 PST 2010 : Invalid reply header from network server:
Invalid string
> Attempt to reuse streams in client on insert gives protocol exception and
> inserts wrong data
> --------------------------------------------------------------------------------------------
>
> Key: DERBY-4315
> URL: https://issues.apache.org/jira/browse/DERBY-4315
> Project: Derby
> Issue Type: Bug
> Components: JDBC
> Affects Versions: 10.1.3.1, 10.2.2.0, 10.3.3.0, 10.4.2.0, 10.5.1.1,
> 10.5.2.0, 10.6.1.0
> Reporter: Kathey Marsden
> Attachments: ReproReuseStream.java, ReproReuseStream.java,
> StreamError.java
>
>
> If a user attempts to reuse a stream set as a parameter to a prepared
> statement, the statement execution should fail with SQL State XJ001. Instead
> client fails with a protocol error and inserts wrong data. See the attached
> java program ReproReuseStream.java for a reproduction.
> [C:/kmarsden/repro/reusestream] java ReproReuseStream
> Insert row 1
> Try to insert row 2 with reused streams
> java.sql.SQLException: Network protocol error: end of stream prematurely
> reached, parameter #4. Remaining data has been
> padded with 0x0.
> at
> org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:96)
> at
> org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:358)
> at
> org.apache.derby.client.am.PreparedStatement.executeUpdate(PreparedStatement.java:399)
> at ReproReuseStream.main(ReproReuseStream.java:41)
> Caused by: org.apache.derby.client.am.SqlException: Network protocol error:
> end of stream prematurely reached, parameter
> #4. Remaining data has been padded with 0x0.
> at
> org.apache.derby.client.net.Request.writePlainScalarStream(Request.java:490)
> at
> org.apache.derby.client.net.Request.writeScalarStream(Request.java:264)
> at
> org.apache.derby.client.net.NetStatementRequest.buildEXTDTA(NetStatementRequest.java:951)
> at
> org.apache.derby.client.net.NetStatementRequest.writeExecute(NetStatementRequest.java:147)
> at
> org.apache.derby.client.net.NetPreparedStatement.writeExecute_(NetPreparedStatement.java:178)
> at
> org.apache.derby.client.am.PreparedStatement.writeExecute(PreparedStatement.java:1801)
> at
> org.apache.derby.client.am.PreparedStatement.flowExecute(PreparedStatement.java:2031)
> at
> org.apache.derby.client.am.PreparedStatement.executeUpdateX(PreparedStatement.java:404)
> at
> org.apache.derby.client.am.PreparedStatement.executeUpdate(PreparedStatement.java:390)
> ... 1 more
> Go ahead and commit so we can see the wrong data.
> ID |MNAME
> |MVALUE |BYTEDATA
> |CHARDATA
> ------------------------------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------------------------------
> ------------------------------------------------------------------------------------------------------------------------
> --------------------------------------------------
> 1 |mname
> |0
> |636363636363636363636363636363636363636363636363636363636363636363636363636363636363636
> 3636363636363636363636363636363636363636&|cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
> ccccccccccccccccccccccccccccccccccccccccccccccccc&
> 2 |mname
> |0
> |000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
> 0000000000000000000000000000000000000000&|
> &
> To workaround the issue users should not attempt to reuse streams but we
> should give a better message and not insert wrong data.
> The code was extracted from StreamingColumnTest testDerby500 but the commits
> were removed.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.