db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kristian Waagan (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-1368) EOFException when reading from blob's binary stream
Date Wed, 19 Dec 2007 15:57:43 GMT

    [ https://issues.apache.org/jira/browse/DERBY-1368?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12553387
] 

Kristian Waagan commented on DERBY-1368:
----------------------------------------

I had a look at the test, and it looks good to me. I ran the test with and without the patch
and observed that the test count changed (98 vs 100). The test succeeded.

I have two questions:
 a) Is the test all about getting the stream and the length twice? If so, maybe the JavaDoc
could say this.
 b) Would it add any value to the test if we drained the stream before getting the stream
the second time?
 c) Would it make sense to also run this with the JDBC-method taking a length argument?

FYI, I noticed there is now a dropTable method in BaseJDBCTestCase, but I'm not sure it adds
value in this test.

+1 to commit

> EOFException when reading from blob's binary stream
> ---------------------------------------------------
>
>                 Key: DERBY-1368
>                 URL: https://issues.apache.org/jira/browse/DERBY-1368
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.1.2.1
>            Reporter: Tobias Bocanegra
>            Assignee: Kathey Marsden
>         Attachments: derby-1368_diff.txt, Derby1368.java
>
>
> reading the 'length()' of a blob reads a previously aquired binary stream.
> test case:
>     public static void main(String[] argv) throws Exception {
>         String driver = "org.apache.derby.jdbc.EmbeddedDriver";
>         String url = "jdbc:derby:derby/test;create=true";
>         Class.forName(driver);
>         Connection con = DriverManager.getConnection(url, "sa", "");
>         con.setAutoCommit(true);
>         // create table
>         System.out.println("1) creating table...");
>         Statement stmt = con.createStatement();
>         stmt.execute("create table T1 (ID char(32) PRIMARY KEY, DATA blob(2G) not null)");
>         stmt.close();
>         // add row
>         System.out.println("2) adding row...");
>         byte[] data = new byte[1024*1024*1];
>         data[0] = 1;
>         data[1] = 2;
>         PreparedStatement s = con.prepareStatement("insert into T1 (ID, DATA) values
(?, ?)");
>         s.setString(1, "id");
>         s.setBytes(2, data);
>         s.execute();
>         s.close();
>         // read row
>         System.out.println("3) reading row...");
>         s = con.prepareStatement("select DATA from T1 where ID = ?");
>         s.setString(1, "id");
>         s.execute();
>         ResultSet rs = s.getResultSet();
>         rs.next();
>         Blob b = rs.getBlob(1);
>         // test output
>         System.out.println("4) Length: " + b.length());
>         InputStream in = b.getBinaryStream();
>         System.out.println("   First Byte: " + in.read());
>         in.close();
>         in = b.getBinaryStream();
>         System.out.println("5) Length: " + b.length());
>         System.out.println("   First Byte: " + in.read());
>         in.close();
>         rs.close();
>         s.close();
>         con.close();
>     }
> gives:
> 1) creating table...
> 2) adding row...
> 3) reading row...
> 4) Length: 1048576
>    First Byte: 1
> 5) Length: 1048576
>    First Byte: -1
> imo, 5) is wrong.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message