This is an automated email from the ASF dual-hosted git repository.

jin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hugegraph.git


The following commit(s) were added to refs/heads/master by this push:
     new 00e040be1 fix(store): handle NPE in getVersion for file (#2897)
00e040be1 is described below

commit 00e040be1459c10c938270a6e9d47e21f3a7b3df
Author: Soyan <[email protected]>
AuthorDate: Mon Nov 3 15:23:30 2025 +0800

    fix(store): handle NPE in getVersion for file (#2897)
    
    * fix(store): fix duplicated definition log root
---
 hugegraph-store/hg-store-core/pom.xml              | 29 ++++++++++++++++++++++
 .../org/apache/hugegraph/store/util/Version.java   |  2 +-
 .../hg-store-core/src/main/resources/version.txt   |  1 +
 .../src/main/resources/log4j2-dev.xml              |  9 +++----
 4 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/hugegraph-store/hg-store-core/pom.xml 
b/hugegraph-store/hg-store-core/pom.xml
index 18abe4937..6f3c4c305 100644
--- a/hugegraph-store/hg-store-core/pom.xml
+++ b/hugegraph-store/hg-store-core/pom.xml
@@ -179,5 +179,34 @@
             <scope>test</scope>
         </dependency>
     </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-resources-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-version</id>
+                        <phase>process-resources</phase>
+                        <goals>
+                            <goal>copy-resources</goal>
+                        </goals>
+                        <configuration>
+                            
<outputDirectory>${project.build.directory}/classes</outputDirectory>
+                            <resources>
+                                <resource>
+                                    <directory>src/main/resources</directory>
+                                    <filtering>true</filtering>
+                                    <includes>
+                                        <include>version.txt</include>
+                                    </includes>
+                                </resource>
+                            </resources>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 
 </project>
diff --git 
a/hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java
 
b/hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java
index a17bd3722..87b36b59a 100644
--- 
a/hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java
+++ 
b/hugegraph-store/hg-store-core/src/main/java/org/apache/hugegraph/store/util/Version.java
@@ -34,7 +34,7 @@ public class Version {
             try (InputStream is = 
Version.class.getResourceAsStream("/version.txt")) {
                 byte[] buf = new byte[64];
                 int len = is.read(buf);
-                version = new String(buf, 0, len);
+                version = new String(buf, 0, len).trim();
             } catch (Exception e) {
                 log.error("Version.getVersion exception: ", e);
             }
diff --git a/hugegraph-store/hg-store-core/src/main/resources/version.txt 
b/hugegraph-store/hg-store-core/src/main/resources/version.txt
new file mode 100644
index 000000000..4d31294f7
--- /dev/null
+++ b/hugegraph-store/hg-store-core/src/main/resources/version.txt
@@ -0,0 +1 @@
+${revision}
diff --git a/hugegraph-store/hg-store-node/src/main/resources/log4j2-dev.xml 
b/hugegraph-store/hg-store-node/src/main/resources/log4j2-dev.xml
index 379acebba..9cf4a50b5 100644
--- a/hugegraph-store/hg-store-node/src/main/resources/log4j2-dev.xml
+++ b/hugegraph-store/hg-store-node/src/main/resources/log4j2-dev.xml
@@ -34,7 +34,7 @@
         <RollingRandomAccessFile name="file" 
fileName="${LOG_PATH}/${FILE_NAME}.log"
                                  
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
                                  bufferedIO="true" bufferSize="524288" 
immediateFlush="true">
-            <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
+            <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
             <PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} 
- %m%n"/>
             <!--JsonLayout compact="true" eventEol="true" complete="true" 
locationInfo="true">
                 <KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd 
HH:mm:ss.SSS}"/>
@@ -61,7 +61,7 @@
         <RollingRandomAccessFile name="raft_file" 
fileName="${LOG_PATH}/${FILE_NAME}_raft.log"
                                  
filePattern="${LOG_PATH}/$${date:yyyy-MM}/${FILE_NAME}-%d{yyyy-MM-dd}-%i.log"
                                  bufferedIO="true" bufferSize="524288" 
immediateFlush="false">
-            <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
+            <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
             <PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} [%t] [%p] %c{1.} 
- %m%n"/>
             <!--JsonLayout compact="true" eventEol="true" complete="true" 
locationInfo="true">
                 <KeyValuePair key="timestamp" value="$${date:yyyy-MM-dd 
HH:mm:ss.SSS}"/>
@@ -88,7 +88,7 @@
         <RollingRandomAccessFile name="audit" 
fileName="${LOG_PATH}/audit-${FILE_NAME}.log"
                                  
filePattern="${LOG_PATH}/$${date:yyyy-MM}/audit-${FILE_NAME}-%d{yyyy-MM-dd-HH}-%i.gz"
                                  bufferedIO="true" bufferSize="524288" 
immediateFlush="false">
-            <ThresholdFilter level="TRACE" onMatch="ACCEPT" onMismatch="DENY"/>
+            <ThresholdFilter level="INFO" onMatch="ACCEPT" onMismatch="DENY"/>
             <!-- Use simple format for audit log to speed up -->
             <!-- PatternLayout pattern="%-d{yyyy-MM-dd HH:mm:ss} - %m%n"/ -->
             <JsonLayout compact="true" eventEol="true" locationInfo="true">
@@ -116,10 +116,7 @@
     <loggers>
         <root level="DEBUG">
             <appender-ref ref="console"/>
-        </root>
-        <root level="INFO">
             <appender-ref ref="file"/>
-            <appender-ref ref="console"/>
         </root>
         <logger name="com.alipay.sofa" level="INFO" additivity="false">
             <appender-ref ref="raft_file"/>

Reply via email to