Skip to content

Commit

Permalink
bugfix: fix code for "sessionMode" not execute problem (apache#4213)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pinocchio2018 committed Dec 17, 2021
1 parent caa8443 commit 8590bbf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions changes/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
- [[#3906](https://github.com/seata/seata/pull/3906)] 支持 SPI 卸载
- [[#3668](https://github.com/seata/seata/pull/3668)] 支持kotlin协程
- [[#4134](https://github.com/seata/seata/pull/4134)] 初始化控制台基础代码
- [[#4213](https://github.com/seata/seata/pull/4213)] 修复部分"sessionMode"代码没执行导致启动失败问题


### bugfix:
Expand Down
1 change: 1 addition & 0 deletions changes/en-us/1.5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
- [[#4177](https://github.com/seata/seata/pull/4177)] fix the problem of accidentally releasing the global lock
- [[#4174](https://github.com/seata/seata/pull/4174)] fix delete undo log connection already closed
- [[#4189](https://github.com/seata/seata/pull/4189)] fix the `kafka-appender.xml` and `logstash-appender.xml`
- [[#4213](https://github.com/seata/seata/pull/4213)] fix code for "sessionMode" not execute problem


### optimize:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ public void onApplicationEvent(ApplicationEvent event) {

ApplicationEnvironmentPreparedEvent environmentPreparedEvent = (ApplicationEnvironmentPreparedEvent)event;
ConfigurableEnvironment environment = environmentPreparedEvent.getEnvironment();

// Load by priority
System.setProperty("sessionMode",
environment.getProperty(SERVER_STORE_SESSION_MODE, environmentPreparedEvent.getEnvironment().getProperty(SERVER_STORE_MODE, "file")));
System.setProperty("lockMode",
environment.getProperty(SERVER_STORE_LOCK_MODE, environmentPreparedEvent.getEnvironment().getProperty(SERVER_STORE_MODE, "file")));

String[] args = environmentPreparedEvent.getArgs();

// port: -h > -D > env > yml > default
Expand Down Expand Up @@ -96,12 +103,6 @@ public void onApplicationEvent(ApplicationEvent event) {
}
String servicePort = String.valueOf(Integer.parseInt(serverPort) + SERVICE_OFFSET_SPRING_BOOT);
setTargetPort(environment, servicePort, true);

// Load by priority
System.setProperty("sessionMode",
environment.getProperty(SERVER_STORE_SESSION_MODE, environmentPreparedEvent.getEnvironment().getProperty(SERVER_STORE_MODE, "file")));
System.setProperty("lockMode",
environment.getProperty(SERVER_STORE_LOCK_MODE, environmentPreparedEvent.getEnvironment().getProperty(SERVER_STORE_MODE, "file")));
}

private void setTargetPort(ConfigurableEnvironment environment, String port, boolean needAddPropertySource) {
Expand Down

0 comments on commit 8590bbf

Please sign in to comment.