Skip to content

Commit 00e040b

Browse files
authored
fix(store): handle NPE in getVersion for file (#2897)
* fix(store): fix duplicated definition log root
1 parent d7697f4 commit 00e040b

4 files changed

Lines changed: 34 additions & 7 deletions

File tree

hugegraph-store/hg-store-core/pom.xml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,5 +179,34 @@
179179
<scope>test</scope>
180180
</dependency>
181181
</dependencies>
182+
<build>
183+
<plugins>
184+
<plugin>
185+
<groupId>org.apache.maven.plugins</groupId>
186+
<artifactId>maven-resources-plugin</artifactId>
187+
<executions>
188+
<execution>
189+
<id>generate-version</id>
190+
<phase>process-resources</phase>
191+
<goals>
192+
<goal>copy-resources</goal>
193+
</goals>
194+
<configuration>
195+
<outputDirectory>${project.build.directory}/classes</outputDirectory>
196+
<resources>
197+
<resource>
198+
<directory>src/main/resources</directory>
199+
<filtering>true</filtering>
200+
<includes>
201+
<include>version.txt</include>
202+
</includes>
203+
</resource>
204+
</resources>
205+
</configuration>
206+
</execution>
207+
</executions>
208+
</plugin>
209+
</plugins>
210+
</build>
182211

183212
</project>

hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public static String getVersion() {
3434
try (InputStream is = Version.class.getResourceAsStream("/version.txt")) {
3535
byte[] buf = new byte[64];
3636
int len = is.read(buf);
37-
version = new String(buf, 0, len);
37+
version = new String(buf, 0, len).trim();
3838
} catch (Exception e) {
3939
log.error("Version.getVersion exception: ", e);
4040
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
${revision}

hugegraph-store/hg-store-node/src/main/resources/log4j2-dev.xml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<RollingRandomAccessFile name="file" fileName="${LOG_PATH}/${FILE_NAME}.log"
3535
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
3636
bufferedIO="true" bufferSize="524288" immediateFlush="true">
37-
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
37+
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
3838
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
3939
<!--JsonLayout compact="true" eventEol="true" complete="true" locationInfo="true">
4040
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd HH:mm:ss.SSS}"/>
@@ -61,7 +61,7 @@
6161
<RollingRandomAccessFile name="raft_file" fileName="${LOG_PATH}/${FILE_NAME}_raft.log"
6262
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
6363
bufferedIO="true" bufferSize="524288" immediateFlush="false">
64-
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
64+
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
6565
<PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} - %m%n"/>
6666
<!--JsonLayout compact="true" eventEol="true" complete="true" locationInfo="true">
6767
<KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd HH:mm:ss.SSS}"/>
@@ -88,7 +88,7 @@
8888
<RollingRandomAccessFile name="audit" fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
8989
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
9090
bufferedIO="true" bufferSize="524288" immediateFlush="false">
91-
<ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
91+
<ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
9292
<!-- Use simple format for audit log to speed up -->
9393
<!-- PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/ -->
9494
<JsonLayout compact="true" eventEol="true" locationInfo="true">
@@ -116,10 +116,7 @@
116116
<loggers>
117117
<root level="DEBUG">
118118
<appender-ref ref="console"/>
119-
</root>
120-
<root level="INFO">
121119
<appender-ref ref="file"/>
122-
<appender-ref ref="console"/>
123120
</root>
124121
<logger name="com.alipay.sofa" level="INFO" additivity="false">
125122
<appender-ref ref="raft_file"/>

0 commit comments

Comments
 (0)