[
https://issues.apache.org/jira/browse/DERBY-5250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13040812#comment-13040812
]
Peter Davis commented on DERBY-5250:
------------------------------------
That was spot on, sorry for wasting your time :/
> Blob is truncating data to 32k~
> -------------------------------
>
> Key: DERBY-5250
> URL: https://issues.apache.org/jira/browse/DERBY-5250
> Project: Derby
> Issue Type: Bug
> Components: SQL
> Affects Versions: 10.7.1.1, 10.8.1.2
> Environment: Windows 7 amd64 running in eclipse using JDBC
> Reporter: Peter Davis
>
> Please be gentle with me, its my first bug post
> I have a curious problem that occurs in the following scenario.
> Having obtained an OutputStream via connection.getBlob() and
> blob.setBinaryStream(1) the following code is run before the transaction is
> commited
> private int[] data = new int[1000000];
> public void saveByteStream(OutputStream os) throws IOException {
> for (int i = 0; i < data.length; i++)
> data[i] = i;
> byte[] byte4 = new byte[4];
> ByteBuffer buf = ByteBuffer.wrap(byte4);
> for (int i = 0; i < data.length; i++) {
> buf.rewind();
> buf.putInt(data[i]);
> os.write(byte4);
> }
> }
> The following is run after obtaining an InputStream from the a ResultSet
> "blob.getBinaryStream()"
> public void loadByteStream(InputStream is) throws IOException {
> byte[] byte4 = new byte[4];
> ByteBuffer buf = ByteBuffer.wrap(byte4);
> for (int i = 0; i < data.length; i++) {
> buf.rewind();
> is.read(byte4);
> data[i] = buf.getInt();
> }
> }
> The array should contain 1000,000 integers each integer having the value of
> the index, unfortunately after index 8166 the data is corrupted
> When these routines are replaced by the following, the problem doesn't occur.
> All other code remaining identical
> public void saveObjectStream(OutputStream os) throws IOException {
> for (int i = 0; i < data.length; i++)
> data[i] = i;
> ObjectOutputStream oos = new ObjectOutputStream(os);
> oos.writeObject(data);
> }
> private void loadObjectStream(InputStream is) throws IOException {
> ObjectInputStream ois = new ObjectInputStream(is);
> try {
> data = (int[]) ois.readObject();
> } catch (ClassNotFoundException e) {
> e.printStackTrace();
> }
> }
> If I direct these routines to a file they both work.
> I'm currently using 10.8.1.2 but have tried 10.7.1.1 with the same result
> Sysinfo gives the following slightly sanitised output
> ------------------ Java Information ------------------
> Java Version: 1.6.0_22
> Java Vendor: Sun Microsystems Inc.
> Java home: C:\Program Files\Java\jre6
> OS name: Windows 7
> OS architecture: amd64
> OS version: 6.1
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.6
> java.runtime.version: 1.6.0_22-b04
> --------- Derby Information --------
> JRE - JDBC: Java SE 6 - JDBC 4.0
> [derby.jar] 10.8.1.2 - (1095077)
> [derbytools.jar] 10.8.1.2 - (1095077)
> [derbynet.jar] 10.8.1.2 - (1095077)
> [derbyclient.jar] 10.8.1.2 - (1095077)
> ------------------------------------------------------
> ----------------- Locale Information -----------------
> Current Locale : [English/United Kingdom [en_GB]]
> Found support for locale: [cs]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [de_DE]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [es]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [fr]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [hu]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [it]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [ja_JP]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [ko_KR]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [pl]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [pt_BR]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [ru]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [zh_CN]
> version: 10.8.1.2 - (1095077)
> Found support for locale: [zh_TW]
> version: 10.8.1.2 - (1095077)
> ------------------------------------------------------
> I presume I'm doing something stupid, but for love nor life can I find it.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira