Mantis - Quercus
Viewing Issue Advanced Details
2094 minor always 10-19-07 14:02 10-19-07 16:20
koreth  
ferg  
normal  
closed 3.1.3  
fixed  
none    
none 3.1.4  
0002094: Null pointer exception in Env.getConnection()
Since I can't reopen a bug:

The patch I provided in bug 2093 was actually for the section of code below the one that was updated in svn revision 3265. That revision doesn't solve the NPE I was seeing.

Updated patch that is more consistent with the code style of rev 3265:

--- a/modules/quercus/src/com/caucho/quercus/env/Env.java
+++ b/modules/quercus/src/com/caucho/quercus/env/Env.java
@@ -695,9 +695,9 @@ public class Env {
 
     Connection conn;
     
- if (oldEntry != null && ! oldEntry.getConnection().isClosed())
- conn = oldEntry.getConnection();
- else {
+ if (oldEntry == null
+ || (conn = oldEntry.getConnection()) == null
+ || conn.isClosed()) {
       if (userName == null || userName.equals(""))
        conn = database.getConnection();
       else


Also, it seems to me that the "_connMap.put()" call should be inside the "else" (in the pre-patched version of the code) rather than unconditional like it is now; the current code is adding a map entry for a ConnectionEntry that has no connection assigned to it whenever the oldEntry connection is used. But it's possible that's as intended.

There are no notes attached to this issue.