Skip to content

Commit 2169210

Browse files
committed
fix: 调用saveDefaultConfig()时,如config.yml为空文件将阻塞主线程
1 parent cf0a96c commit 2169210

File tree

6 files changed

+17
-18
lines changed

6 files changed

+17
-18
lines changed

dependency-reduced-pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>com.meteor</groupId>
55
<artifactId>wechat-bc</artifactId>
6-
<version>1.1.1-SNAPSHOT</version>
6+
<version>1.1.2-SNAPSHOT</version>
77
<build>
88
<plugins>
99
<plugin>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.meteor</groupId>
88
<artifactId>wechat-bc</artifactId>
9-
<version>1.1.2-SNAPSHOT</version>
9+
<version>1.1.3-SNAPSHOT</version>
1010

1111
<distributionManagement>
1212
<repository>

release_info.info

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION=v1.1.2
2-
DESCRIPTION=feat: 消息撤回接口
3-
feat: RevokeMessage
1+
VERSION=v1.1.3
2+
DESCRIPTION=fix: 调用saveDefaultConfig()时,如config.yml为空文件将阻塞主线程
3+
44

src/main/java/com/meteor/wechatbc/impl/plugin/BasePlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void saveDefaultConfig(){
9595
FileOutputStream fileOutputStream = new FileOutputStream(new File(getDataFolder(), "config.yml"));
9696
) {
9797
byte[] bytes = new byte[resource.available()];
98+
if(bytes.length==0) return;
9899
int length = 0;
99100
while ((length = resource.read(bytes))!=-1){
100101
fileOutputStream.write(bytes,0,length);

src/main/java/com/meteor/wechatbc/impl/plugin/PluginManager.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public PluginManager(WeChatClient weChatClient){
2929
if(!pluginsFolder.exists()){
3030
pluginsFolder.mkdirs();
3131
}
32+
PluginLoader.logger.info("开始载入插件");
3233
for (File pluginFile : pluginsFolder.listFiles()) {
3334
if(pluginFile.isFile()){
3435
this.loadPlugin(pluginFile);
@@ -60,6 +61,10 @@ public void loadPlugin(File file){
6061
PluginLoader.logger.info("插件 [{}] 已存在,无法重新加载",pluginDescription.getName());
6162
return;
6263
}
64+
65+
66+
PluginLoader.logger.info("正在载入插件{}",pluginDescription.getName());
67+
6368
URL[] urls = new URL[0];
6469
try {
6570
urls = new URL[]{ file.toURI().toURL() };
@@ -78,26 +83,19 @@ public void loadPlugin(File file){
7883
// 解析指令并创建实例
7984
pluginDescription.getCommands().forEach(mainCommand->{
8085
WeChatCommand weChatCommand = new WeChatCommand(mainCommand);
86+
PluginLoader.logger.info(" 解析指令 {}",weChatCommand.getMainCommand());
8187
weChatClient.getCommandManager().registerCommand(weChatCommand);
8288
});
8389
}
8490
pluginMap.put(pluginDescription.getName(),plugin);
8591
// 初始化插件
92+
PluginLoader.logger.info(" 初始化 {}",pluginDescription.getMain());
8693
plugin.init(pluginDescription,weChatClient);
8794
// 调用插件启动hook
8895
plugin.onEnable();
89-
} catch (MalformedURLException e) {
90-
throw new RuntimeException(e);
91-
} catch (ClassNotFoundException e) {
92-
throw new RuntimeException(e);
93-
} catch (InvocationTargetException e) {
94-
throw new RuntimeException(e);
95-
} catch (InstantiationException e) {
96-
throw new RuntimeException(e);
97-
} catch (IllegalAccessException e) {
98-
throw new RuntimeException(e);
99-
} catch (NoSuchMethodException e) {
100-
throw new RuntimeException(e);
96+
PluginLoader.logger.info("已载入 {}",pluginDescription.getName());
97+
} catch (Exception e){
98+
e.printStackTrace();
10199
}
102100
}
103101
}

src/main/java/com/meteor/wechatbc/util/VersionCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class VersionCheck {
1212

13-
private static final String CURRENT_VERSION = "v1.1.1";
13+
private static final String CURRENT_VERSION = "v1.1.2";
1414

1515
public static void check(String owner, String repo) {
1616

0 commit comments

Comments
 (0)