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(); } } }
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.