db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-333) Malformed if statement in org.apache.derby.impl.drda.Database.getDRDAStatement()
Date Tue, 20 Dec 2005 23:19:32 GMT
    [ http://issues.apache.org/jira/browse/DERBY-333?page=comments#action_12360995 ] 

Bryan Pendleton commented on DERBY-333:
---------------------------------------

I was interested in this bug, too, but I don't know the answer. The way that I read
the code, the "if" statement is trying to be an optimization, but I don't think there
is a need to optimize this code, for the body of the if statement is just a single
hashtable lookup. 

In my opinion the entire getDRDAStatement() method should be re-written to read:

  DRDAStatement newStmt = (DRDAStatement)stmtTable.get(getStmtKey(pkgnamcsn));
  if (newStmt != null)
  {
    currentStatement = newStmt;
    currentStatement.setCurrentDrdaResultSet(pkgnamcsn);
  }
  return newStmt;

I think that would be simpler and more self-evident than the current code.

The fact that simply removing the semi-colon broke the tests is interesting; it would
appear to mean that there are paths through the code in which the "if" statement
evaluates to false, but either currentStatement is not actually correct, or we need
to call currentStatement.setCurrentDrdaResultSet(). My bet is that it's the latter: I
think that if you just remove the semicolon, you would break cases where the client
is trying to switch between different result sets on the same statement.


> Malformed if statement in org.apache.derby.impl.drda.Database.getDRDAStatement()
> --------------------------------------------------------------------------------
>
>          Key: DERBY-333
>          URL: http://issues.apache.org/jira/browse/DERBY-333
>      Project: Derby
>         Type: Bug
>   Components: Network Server
>     Versions: 10.1.1.0
>  Environment: ------------------ Java Information ------------------
> Java Version:    1.4.2_05
> Java Vendor:     Sun Microsystems Inc.
> Java home:       C:\Program Files\Java\j2re1.4.2_05
> Java classpath:  c:\eclipse\db2jcc.jar;c:\eclipse\db2jcc_license_c.jar;C:\derby\derbyRecent\tools\java\jakarta-oro-2.0.8.jar;c:\derby\derbyRecent\classes;.
> OS name:         Windows XP
> OS architecture: x86
> OS version:      5.1
> Java user name:  050503w
> Java user home:  C:\Documents and Settings\050503w
> Java user dir:   C:\derby\derbyRecent\classes
> java.specification.name: Java Platform API Specification
> java.specification.version: 1.4
> --------- Derby Information --------
> JRE - JDBC: J2SE 1.4.2 - JDBC 3.0
> [C:\eclipse\db2jcc.jar] 2.4 - (17)
> [C:\eclipse\db2jcc_license_c.jar] 2.4 - (17)
> [C:\derby\derbyRecent\classes] 10.1.0.0 alpha - (???)
> [C:\derby\derbyRecent\classes] 10.1.0.0 alpha - (???)
> ------------------------------------------------------
>     Reporter: Philip Wilder

>
> Semicolon where it should not be (see the <!-- --> comment):
> 	protected DRDAStatement getDRDAStatement(String pkgnamcsn) 
> 		throws SQLException
> 	{
> 		// Need to get the short version because resultSets have different
> 		// corelation ids.
> 		String key = getStmtKey(pkgnamcsn);
> 		DRDAStatement newStmt = null;
> 		// If our current statement doesn't match,retrieve the statement
> 		// and make it current if not null.
>             // <!-- Note the semicolon after the if statement -->
> 		if (currentStatement == null || 
> 			!key.equals(getStmtKey(currentStatement.getPkgnamcsn()))); 
> 			{
> 				newStmt  = (DRDAStatement) stmtTable.get(key);				
> 			}
> 			
> 			if (newStmt != null)	 // don't blow away currentStatement if we can't find this one
> 				currentStatement = newStmt;
> 			else
> 				return null;
> 		// Set the correct result set.
> 		currentStatement.setCurrentDrdaResultSet(pkgnamcsn);
> 		return currentStatement;
> 	}
> Solution is to remove the semicolon, all that is needed is a committer.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message