forked from apache/ignite
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GG-17339 Backport [IGNITE-11524] Memory leak caused by executing a jd…
…bc prepared statement
- Loading branch information
tledkov
committed
May 6, 2019
1 parent
c4783d3
commit 55f6ed0
Showing
4 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../clients/src/test/java/org/apache/ignite/jdbc/thin/JdbcThinPreparedStatementLeakTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* Copyright 2019 GridGain Systems, Inc. and Contributors. | ||
* | ||
* Licensed under the GridGain Community Edition License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.gridgain.com/products/software/community-edition/gridgain-community-edition-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.ignite.jdbc.thin; | ||
|
||
import org.apache.ignite.IgniteJdbcThinDriver; | ||
import org.apache.ignite.internal.util.typedef.internal.U; | ||
import org.junit.Test; | ||
|
||
import java.sql.Connection; | ||
import java.sql.PreparedStatement; | ||
import java.sql.ResultSet; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
|
||
/** | ||
* Prepared statement leaks test. | ||
*/ | ||
@SuppressWarnings("ThrowableNotThrown") | ||
public class JdbcThinPreparedStatementLeakTest extends JdbcThinAbstractSelfTest { | ||
/** URL. */ | ||
private static final String URL = "jdbc:ignite:thin://127.0.0.1/"; | ||
|
||
|
||
/** {@inheritDoc} */ | ||
@Override protected void beforeTest() throws Exception { | ||
super.beforeTest(); | ||
|
||
startGrid(); | ||
} | ||
|
||
/** {@inheritDoc} */ | ||
@Override protected void afterTest() throws Exception { | ||
stopAllGrids(); | ||
|
||
super.afterTest(); | ||
} | ||
|
||
/** | ||
* @throws Exception If failed. | ||
*/ | ||
@SuppressWarnings("StatementWithEmptyBody") | ||
@Test | ||
public void test() throws Exception { | ||
try (Connection conn = new IgniteJdbcThinDriver().connect(URL, new Properties())) { | ||
for (int i = 0; i < 50000; ++i) { | ||
try (PreparedStatement st = conn.prepareStatement("select 1")) { | ||
ResultSet rs = st.executeQuery(); | ||
|
||
while (rs.next()) { | ||
// No-op. | ||
} | ||
|
||
rs.close(); | ||
} | ||
} | ||
|
||
Set stmts = U.field(conn, "stmts"); | ||
|
||
assertEquals(0, stmts.size()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters