Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #31372 problem #31375

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,17 @@ public List<String> getChildrenKeys(final String key) {

@Override
public boolean isExisted(final String key) {
return !Strings.isNullOrEmpty(query(key));
try (
Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(repositorySQL.getSelectByKeySQL())) {
preparedStatement.setString(1, key);
try (ResultSet resultSet = preparedStatement.executeQuery()) {
return resultSet.next();
}
} catch (final SQLException ex) {
log.error("Get {} data by key: {} failed", getType(), key, ex);
}
return Boolean.FALSE;
}

@Override
Expand All @@ -138,9 +148,8 @@ public void persist(final String key, final String value) {
// Create key level directory recursively.
for (int i = 0; i < paths.length - 1; i++) {
String tempKey = tempPrefix + SEPARATOR + paths[i];
String tempKeyVal = query(tempKey);
if (Strings.isNullOrEmpty(tempKeyVal)) {
insert(tempKey, "", parent);
if (isExisted(tempKey)){
update(tempKey, value);
}
tempPrefix = tempKey;
parent = tempKey;
Expand Down
Loading