Skip to content

Commit 08cf862

Browse files
authored
improve: add auto version number. (#96)
Co-authored-by: xhaopan <[email protected]>
1 parent 7461946 commit 08cf862

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/org/apache/hadoop/fs/CosNConfigKeys.java

+19-1
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,32 @@
55
import org.apache.hadoop.fs.cosn.Constants;
66
import org.apache.hadoop.fs.cosn.Unit;
77

8+
import java.io.IOException;
9+
import java.io.InputStream;
10+
import java.util.Properties;
11+
812
/**
913
* This class contains constants for configuration keys used in the cos file system.
1014
*/
1115
@InterfaceAudience.Private
1216
@InterfaceStability.Unstable
1317
public class CosNConfigKeys extends CommonConfigurationKeys {
1418
public static final String USER_AGENT = "fs.cosn.user.agent";
15-
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v8.2.0";
19+
20+
private static String version;
21+
22+
static {
23+
String path = "META-INF/maven/com.qcloud.cos/hadoop-cos/pom.properties";
24+
Properties properties = new Properties();
25+
try (InputStream in = CosNConfigKeys.class.getClassLoader().getResourceAsStream(path)) {
26+
properties.load(in);
27+
version = properties.getProperty("version");
28+
} catch (IOException e) {
29+
version = "unknown";
30+
}
31+
}
32+
33+
public static final String DEFAULT_USER_AGENT = "cos-hadoop-plugin-v" + version;
1634

1735
public static final String TENCENT_EMR_VERSION_KEY = "fs.emr.version";
1836

0 commit comments

Comments
 (0)