[ https://issues.apache.org/jira/browse/DERBY-7128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17448820#comment-17448820 ]
Eric Kaplan commented on DERBY-7128: ------------------------------------ [~rhillegas] To deserialize out of the column we are doing this (I removed exception handling for simplicity of reading...) {code:java} ResultSet rs = <some result set> String columnName = <my blob column name> InputStream is = rs.getBinaryStream(columnName); ObjectInputStream oids = new ObjectInputStream(is); Object o = ois.readObject(); {code} To serialize in: {code:java} Object obj = <object to serialize> PreparedStatement pstatement = buildPreparedStatement(); ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(bos); oos.writeObject(obj); oos.close(); byte[] bytes = bos.toByteArray(); pstmt.setBinaryStream(columnNumber, oos, bytes.length); {code} Note in this case the objects are pretty small. What's odd is that we are hitting this with a fairly small table that has three records. Every so often the deserialization fails with the error in this ticket. It's actually part of our CI/regression pipeline. We have a static Derby database that we then _upgrade_ to the current version, which involves selecting blobs out of this one table. > ArrayIndexOutOfBoundsException: -1 thrown when calliing > BlobLocatorInputStream.read > ----------------------------------------------------------------------------------- > > Key: DERBY-7128 > URL: https://issues.apache.org/jira/browse/DERBY-7128 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.14.2.0 > Reporter: Eric Kaplan > Priority: Major > > We have seen this issue sporadically reading from a database table with a > column that is a BLOB. The exception is: > {code:java} > 0713 15:26:13,774 ERROR [main] java.lang.ArrayIndexOutOfBoundsException: -1 > 0713 15:26:13,774 ERROR [main] at > org.apache.derby.client.net.Request.popMark(Unknown Source) > 0713 15:26:13,774 ERROR [main] at > org.apache.derby.client.net.Request.popMarkForCachingPKGNAMCSN(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.net.NetPackageRequest.storePKGNAMCBytes(Unknown > Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.net.NetPackageRequest.buildPKGNAMCSN(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.net.NetStatementRequest.buildEXCSQLSTT(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.net.NetStatementRequest.writeExecuteCall(Unknown > Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.net.NetStatement.writeExecuteCall_(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.ClientStatement.writeExecuteCall(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.ClientPreparedStatement.flowExecute(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.ClientPreparedStatement.executeX(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.CallableLocatorProcedures.blobGetLength(Unknown > Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.ClientBlob.getLocatorLength(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.Lob.sqlLength(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.BlobLocatorInputStream.readBytes(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.BlobLocatorInputStream.read(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > java.io.BufferedInputStream.fill(BufferedInputStream.java:246) > 0713 15:26:13,775 ERROR [main] at > java.io.BufferedInputStream.read1(BufferedInputStream.java:286) > 0713 15:26:13,775 ERROR [main] at > java.io.BufferedInputStream.read(BufferedInputStream.java:345) > 0713 15:26:13,775 ERROR [main] at > java.io.FilterInputStream.read(FilterInputStream.java:133) > 0713 15:26:13,775 ERROR [main] at > org.apache.derby.client.am.CloseFilterInputStream.read(Unknown Source) > 0713 15:26:13,775 ERROR [main] at > java.io.ObjectInputStream$PeekInputStream.read(ObjectInputStream.java:2720) > 0713 15:26:13,775 ERROR [main] at > java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2736) > 0713 15:26:13,776 ERROR [main] at > java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:3213) > 0713 15:26:13,776 ERROR [main] at > java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:896) > 0713 15:26:13,776 ERROR [main] at > java.io.ObjectInputStream.<init>(ObjectInputStream.java:358) > 0713 15:26:13,776 ERROR [main] at > com.armanta.ejb.SimpleJDBCAbstractionWithBlobs.getBlobColumnAsObject(SimpleJDBCAbstractionWithBlobs.java:163) > 0713 15:26:13,776 ERROR [main] at > com.armanta.ejb.SimpleJDBCAbstractionWithBlobs.getBlobColumnAsObjectRecogniseError(SimpleJDBCAbstractionWithBlobs.java:138) > 0713 15:26:13,776 ERROR [main] at > com.armanta.upgrade.Upgrade_6_0_8_4_BranchBlobs.processTable(Upgrade_6_0_8_4_BranchBlobs.java:84) > 0713 15:26:13,776 ERROR [main] at > com.armanta.upgrade.Upgrade_6_0_8_4_BranchBlobs.upgrade(Upgrade_6_0_8_4_BranchBlobs.java:57) > 0713 15:26:13,776 ERROR [main] at > com.armanta.upgrade.Upgrade.doIt(Upgrade.java:117) > 0713 15:26:13,776 ERROR [main] at > com.armanta.upgrade.Upgrade.main(Upgrade.java:50) > {code} > When this happens we are unable to read the blob from the table. -- This message was sent by Atlassian Jira (v8.20.1#820001)