aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-18 11:16:03 +0300
committerGravatar Vitaly Takmazov2022-12-18 11:16:03 +0300
commiteaf04f18001159cf5aaa3c9747a300b48e8d3f2f (patch)
tree999792417c3a3fe8c6048f94b354399738e67d1c /src/main/java/com/juick/service
parentbb215f6373b32f0e54cdf04f9b88ced54785e54d (diff)
Correct unwrapped DataSource connection usage
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/PostgreGINService.java8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main/java/com/juick/service/PostgreGINService.java b/src/main/java/com/juick/service/PostgreGINService.java
index ca326bd5..583836a7 100644
--- a/src/main/java/com/juick/service/PostgreGINService.java
+++ b/src/main/java/com/juick/service/PostgreGINService.java
@@ -49,11 +49,9 @@ public class PostgreGINService extends BaseJdbcService implements SearchService
DataSource dataSource;
private String escapeQuery(String searchString) {
- try {
- if (dataSource.getConnection().isWrapperFor(PGConnection.class)) {
- PGConnection connection = dataSource.getConnection().unwrap(PGConnection.class);
- return connection.escapeLiteral(searchString);
- }
+ try (var connection = dataSource.getConnection()) {
+ var pg = connection.unwrap(PGConnection.class);
+ return pg.escapeLiteral(searchString);
} catch (SQLException e) {
e.printStackTrace();
}