Return-Path: X-Original-To: apmail-db-derby-dev-archive@www.apache.org Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0D727C280 for ; Fri, 26 Jul 2013 17:43:52 +0000 (UTC) Received: (qmail 92304 invoked by uid 500); 26 Jul 2013 17:43:51 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 92287 invoked by uid 500); 26 Jul 2013 17:43:51 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 91955 invoked by uid 99); 26 Jul 2013 17:43:51 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 26 Jul 2013 17:43:51 +0000 Date: Fri, 26 Jul 2013 17:43:51 +0000 (UTC) From: "Kathey Marsden (JIRA)" To: derby-dev@db.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (DERBY-5872) Inconsistency between isWrapperFor() and unwrap() in logical statements MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/DERBY-5872?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13720985#comment-13720985 ] Kathey Marsden commented on DERBY-5872: --------------------------------------- One thing to note is that the list is just a list of issues to consider for backport, so if upon analysis it looks like it is not a bug that would likely be hit or is difficult to backport, it is sensible to mark it backport reject and move on. > Inconsistency between isWrapperFor() and unwrap() in logical statements > ----------------------------------------------------------------------- > > Key: DERBY-5872 > URL: https://issues.apache.org/jira/browse/DERBY-5872 > Project: Derby > Issue Type: Bug > Components: JDBC > Affects Versions: 10.4.1.3, 10.5.1.1, 10.6.1.0, 10.7.1.1, 10.8.1.2, 10.9.1.0 > Reporter: Knut Anders Hatlen > Assignee: Knut Anders Hatlen > Fix For: 10.10.1.1 > > Attachments: derby-5872-1a.diff > > > I noticed this when I refactored the logical statement classes in DERBY-5868. The isWrapperFor() method forwards calls to the underlying physical statement, but the unwrap() method works purely at the logical level. > For example, if you produce a LogicalPreparedStatement40 instance with this code > ClientConnectionPoolDataSource ds = new ClientConnectionPoolDataSource(); > ds.setDatabaseName("testdb"); > ds.setCreateDatabase("create"); > ds.setMaxStatements(10); > PooledConnection pc = ds.getPooledConnection(); > Connection c = pc.getConnection(); > PreparedStatement ps = c.prepareStatement("values 1"); > you'll see that > System.out.println(ps.isWrapperFor(LogicalPreparedStatement40.class)); > prints false, telling that ps is not a wrapper for LogicalPreparedStatement40. However, trying to unwrap ps as a LogicalPreparedStatement succeeds: > LogicalPreparedStatement40 lps = ps.unwrap(LogicalPreparedStatement40.class); > On the other hand > System.out.println(ps.isWrapperFor(PreparedStatement40.class)); > prints true, indicating that ps is a wrapper for PreparedStatement40, but trying to unwrap it as one, fails: > PreparedStatement40 ps4 = ps.unwrap(PreparedStatement40.class); > Exception in thread "main" java.sql.SQLException: Unable to unwrap for 'class org.apache.derby.client.am.PreparedStatement40' > at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:108) > at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:364) > at org.apache.derby.client.am.LogicalStatementEntity.unwrap(LogicalStatementEntity.java:258) > at org.apache.derby.client.am.LogicalPreparedStatement.unwrap(LogicalPreparedStatement.java:57) > at Test.main(Test.java:37) > Caused by: org.apache.derby.client.am.SqlException: Unable to unwrap for 'class org.apache.derby.client.am.PreparedStatement40' > ... 3 more -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira