This is an automated email from the ASF dual-hosted git repository.
jmclean pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/gravitino.git
The following commit(s) were added to refs/heads/main by this push:
new 9db0463e03 [#7704] feat(common): Close stream in Version (#7718)
9db0463e03 is described below
commit 9db0463e03b3367c458383c159dbc0b8265f8256
Author: BIN <[email protected]>
AuthorDate: Wed Jul 16 09:34:04 2025 +0800
[#7704] feat(common): Close stream in Version (#7718)
### What changes were proposed in this pull request?
Close stream in Version.java
### Why are the changes needed?
Fix: #7704
### Does this PR introduce _any_ user-facing change?
no
### How was this patch tested?
junit
Co-authored-by: senlizishi <[email protected]>
---
common/src/main/java/org/apache/gravitino/Version.java | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/common/src/main/java/org/apache/gravitino/Version.java
b/common/src/main/java/org/apache/gravitino/Version.java
index f0d71a91c4..d327656b4a 100644
--- a/common/src/main/java/org/apache/gravitino/Version.java
+++ b/common/src/main/java/org/apache/gravitino/Version.java
@@ -19,6 +19,7 @@
package org.apache.gravitino;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Properties;
import org.apache.gravitino.dto.VersionDTO;
import org.apache.gravitino.exceptions.GravitinoRuntimeException;
@@ -33,10 +34,16 @@ public class Version {
private Version() {
Properties projectProperties = new Properties();
- try {
+ try (InputStream inputStream =
+
Version.class.getClassLoader().getResourceAsStream("gravitino-build-info.properties"))
{
+ if (inputStream == null) {
+ throw new GravitinoRuntimeException(
+ new IOException("Resource gravitino-build-info.properties not
found"),
+ "Failed to get Gravitino version: Build info properties file is
missing.");
+ }
+
VersionInfo currentVersionInfo = new VersionInfo();
- projectProperties.load(
-
Version.class.getClassLoader().getResourceAsStream("gravitino-build-info.properties"));
+ projectProperties.load(inputStream);
currentVersionInfo.version =
projectProperties.getProperty("project.version");
currentVersionInfo.compileDate =
projectProperties.getProperty("compile.date");
currentVersionInfo.gitCommit =
projectProperties.getProperty("git.commit.id");