Skip to content

Commit ce80946

Browse files
committed
extract the loadProperties function
1 parent 4689874 commit ce80946

4 files changed

Lines changed: 21 additions & 38 deletions

File tree

hugegraph-commons/hugegraph-common/src/main/java/org/apache/hugegraph/util/VersionUtil.java

Lines changed: 19 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -104,60 +104,44 @@ public static String getImplementationVersion(String manifestPath) {
104104
.getValue(Attributes.Name.IMPLEMENTATION_VERSION);
105105
}
106106

107-
/**
108-
* Get version from properties
109-
* @return The common version
110-
*/
111-
public static String getVersionFromProperties() {
112-
final Properties PROPS = new Properties();
107+
public static Properties loadProperties() {
108+
final Properties props = new Properties();
113109

114110
try (InputStream is =
115111
VersionUtil.class.getResourceAsStream("/version.properties")) {
116-
PROPS.load(is);
112+
props.load(is);
117113
} catch (IOException e) {
118114
throw new RuntimeException("Could not load version.properties", e);
119115
}
120-
return PROPS.getProperty("Version");
116+
return props;
117+
}
118+
119+
/**
120+
* Get version from properties
121+
* @return The common version
122+
*/
123+
public static String getVersionFromProperties() {
124+
Properties props = loadProperties();
125+
return props.getProperty("Version");
121126
}
122127

123128
/**
124129
* Get api version from properties
125130
* @return The api version
126131
*/
127132
public static String getApiVersionFromProperties() {
128-
final Properties PROPS = new Properties();
129-
130-
try (InputStream is =
131-
VersionUtil.class.getResourceAsStream("/version.properties")) {
132-
PROPS.load(is);
133-
} catch (IOException e) {
134-
throw new RuntimeException("Could not load version.properties", e);
135-
}
136-
return PROPS.getProperty("ApiVersion");
133+
Properties props = loadProperties();
134+
return props.getProperty("ApiVersion");
137135
}
138136

139137
public static String getApiCheckBeginVersionFromProperties() {
140-
final Properties PROPS = new Properties();
141-
142-
try (InputStream is =
143-
VersionUtil.class.getResourceAsStream("/version.properties")) {
144-
PROPS.load(is);
145-
} catch (IOException e) {
146-
throw new RuntimeException("Could not load version.properties", e);
147-
}
148-
return PROPS.getProperty("ApiCheckBeginVersion");
138+
Properties props = loadProperties();
139+
return props.getProperty("ApiCheckBeginVersion");
149140
}
150141

151142
public static String getApiCheckEndVersionFromProperties() {
152-
final Properties PROPS = new Properties();
153-
154-
try (InputStream is =
155-
VersionUtil.class.getResourceAsStream("/version.properties")) {
156-
PROPS.load(is);
157-
} catch (IOException e) {
158-
throw new RuntimeException("Could not load version.properties", e);
159-
}
160-
return PROPS.getProperty("ApiCheckEndVersion");
143+
Properties props = loadProperties();
144+
return props.getProperty("ApiCheckEndVersion");
161145
}
162146

163147
/**

hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/server/ApplicationConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.apache.tinkerpop.gremlin.server.util.MetricManager;
2929
import org.glassfish.hk2.api.Factory;
3030
import org.glassfish.hk2.api.MultiException;
31-
import org.glassfish.hk2.api.ServiceLocator;
3231
import org.glassfish.hk2.utilities.binding.AbstractBinder;
3332
import org.glassfish.jersey.process.internal.RequestScoped;
3433
import org.glassfish.jersey.server.ResourceConfig;

hugegraph-server/hugegraph-dist/src/assembly/travis/start-pd.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -ev
1919

2020
HOME_DIR=$(pwd)
2121
source $HOME_DIR/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
22-
PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-incubating-${version}
22+
PD_DIR=$HOME_DIR/hugegraph-pd/apache-hugegraph-pd-incubating-${Version}
2323

2424
pushd $PD_DIR
2525
. bin/start-hugegraph-pd.sh

hugegraph-server/hugegraph-dist/src/assembly/travis/start-store.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ set -ev
1919

2020
HOME_DIR=$(pwd)
2121
source $HOME_DIR/hugegraph-commons/hugegraph-common/src/main/resources/version.properties
22-
STORE_DIR=$HOME_DIR/hugegraph-store/apache-hugegraph-store-incubating-${version}
22+
STORE_DIR=$HOME_DIR/hugegraph-store/apache-hugegraph-store-incubating-${Version}
2323

2424
pushd $STORE_DIR
2525
. bin/start-hugegraph-store.sh

0 commit comments

Comments
 (0)