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

Fixed resource leaks #379

Merged
merged 1 commit into from
Mar 24, 2025
Merged
Show file tree
Hide file tree
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
@@ -1,6 +1,7 @@
package tech.ydb.core.ssl;

import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.KeyStoreException;
import java.security.NoSuchAlgorithmException;
Expand All @@ -16,7 +17,7 @@
import javax.net.ssl.X509TrustManager;

final class YandexTrustManagersProvider {
private static final String JSK_YANDEX_CA_STORE = "certificates/YandexAllCAs.pkcs";
private static final String YANDEX_CA_STORE = "certificates/YandexAllCAs.pkcs";
private static final String STORE_PASSWORD = "yandex";

private final TrustManager[] trustManagers;
Expand Down Expand Up @@ -51,8 +52,9 @@ private List<TrustManager> getDefaultTrustManagers() throws NoSuchAlgorithmExcep
private List<TrustManager> getCustomTrustManagers()
throws KeyStoreException, IOException, NoSuchAlgorithmException, CertificateException {
KeyStore keyStore = KeyStore.getInstance("PKCS12");
keyStore.load(YandexTrustManagersProvider.class.getClassLoader().getResourceAsStream(JSK_YANDEX_CA_STORE),
STORE_PASSWORD.toCharArray());
try (InputStream is = YandexTrustManagersProvider.class.getClassLoader().getResourceAsStream(YANDEX_CA_STORE)) {
keyStore.load(is, STORE_PASSWORD.toCharArray());
}
return getTrustManagersFromKeyStore(keyStore);
}

Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/tech/ydb/core/utils/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ private Version() {
}

public static Optional<String> getVersion() {
try {
try (InputStream in = Version.class.getResourceAsStream("/ydb_sdk_version.properties")) {
Properties prop = new Properties();
InputStream in = Version.class.getResourceAsStream("/ydb_sdk_version.properties");
prop.load(in);
return Optional.ofNullable(prop.getProperty("version"));
} catch (Exception ex) {
Expand Down
Loading