@@ -0,0 +1,1886 @@
+/*%0A * Copyright (C) 2004 - 2013 Brian McCallister%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.skife.jdbi.v2.sqlobject;%0A%0Aimport java.sql.Connection;%0Aimport java.sql.SQLException;%0A%0Aimport org.h2.jdbcx.JdbcDataSource;%0Aimport org.junit.Test;%0Aimport org.skife.jdbi.v2.DBI;%0A%0Aimport junit.framework.TestCase;%0A%0A/**%0A * Sometimes the GC will call %7B@link #finalize()%7D on a SqlObject from%0A * extremely sensitive places from within the GC machinery.  JDBI should not%0A * open a %7B@link Connection%7D just to satisfy a (no-op) finalizer.%0A * %3Ca href=%22https://github.com/brianm/jdbi/issues/82%22%3EIssue #82%3C/a%3E.%0A */%0Apublic class TestFinalizeBehavior extends TestCase%0A%7B%0A    private DBI    dbi;%0A%0A    interface UselessDao%0A    %7B%0A        public void finalize();%0A    %7D%0A%0A    @Test%0A    public void testFinalizeDoesntConnect() throws Exception%0A    %7B%0A        final UselessDao dao = dbi.onDemand(UselessDao.class);%0A        dao.finalize(); // Normally GC would do this, but just fake it%0A    %7D%0A%0A    @Override%0A    public void setUp() throws Exception%0A    %7B%0A        final JdbcDataSource ds = new JdbcDataSource() %7B%0A            private static final long serialVersionUID = 1L;%0A%0A            @Override%0A            public Connection getConnection() throws SQLException%0A            %7B%0A                throw new UnsupportedOperationException();%0A            %7D%0A        %7D;%0A        dbi = new DBI(ds);%0A    %7D%0A%7D%0A

Add a test case showing that SqlObject finalize() calls open Connections.