Bug 281 : Connection Leak for erroring queries with implicit transaction demarcation
Priority 
High
Reported Version 
 
Logged By 
Rob
Status 
Fixed
Fixed Version 
2.6.0
Assigned To 
 
Product 
Ebean - core
Duplicate Of 
 
Created 
20/04/2010
Updated 
20/04/2010
Type 
Bug
 
Attachments 
No attachments

Failing Testcase from Rien:

package com.avaje.tests.query;

import com.avaje.ebean.Ebean;
import com.avaje.ebean.Query;

import junit.framework.TestCase;


import com.avaje.ebeaninternal.server.core.DefaultBackgroundExecutor;
import com.avaje.tests.compositekeys.db.Customer;

public class TestConnectionCloseOnException extends TestCase {

    public void test() {

        try {
            for (int i = 0; i < 100; i++) {
                try {
                    Query<Customer> q0 = Ebean.find(Customer.class).where().icontains("namexxx", "Rob").query();

                    q0.findList();
                } catch (Exception e) {
                    if (e.getMessage().contains("Unsuccessfully waited")) {
                        fail("No connections found while only one thread is running. (after "+i+" queries)");
                    } else {
                        e.printStackTrace();
                    }
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
 
Rob 20 Apr 07:55
The issue

The issue here is that a OrmQueryRequest had a private field "createdTransaction" that hid an inherited field of the same name in BeanRequest. So the BeanRequest.rollbackTransIfRequired() used the wrong value for "createdTransaction".

Fixed in HEAD.

woResponse

Upload a file