Skip to content

Commit

Permalink
fix: the configuration file cannot be found in the IDE plugin (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
styluo authored Oct 8, 2024
1 parent 130032b commit 6d9c88a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,18 @@ private int doSend(RequestDto requestDto) throws Exception {
httpConn.setDoOutput(true);

DataOutputStream outputStream = null;
InputStream inputStream = null;
try {
httpConn.connect();
outputStream = new DataOutputStream(httpConn.getOutputStream());
outputStream.write(requestDto.getBytes());
outputStream.flush();
int responseCode = httpConn.getResponseCode();
inputStream = httpConn.getInputStream();

return responseOk(responseCode);
} finally {
if (outputStream != null) {
outputStream.close();
}
if (inputStream != null) {
inputStream.close();
}
}
}

Expand Down
11 changes: 10 additions & 1 deletion src/main/java/io/growing/sdk/java/utils/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.growing.sdk.java.utils;

import io.growing.sdk.java.GrowingAPI;
import io.growing.sdk.java.exception.GIOMessageException;
import io.growing.sdk.java.logger.GioLogger;

Expand All @@ -24,7 +25,15 @@ public static void initDefault() {
try {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream gioDefaultProps = classLoader.getResourceAsStream("gio_default.properties");
prop.load(gioDefaultProps);
if (gioDefaultProps != null) {
prop.load(gioDefaultProps);
} else {
// 通过加载GrowingAPI的ClassLoader来加载默认配置文件,IDE Plugin开发模式下,会使用自定义ClassLoader加载对应的plugin jar及dependencies
// 建议用户根据使用环境将对应properties配置文件加载到内存中直接通过init方法传入
ClassLoader defaultClassLoader = GrowingAPI.class.getClassLoader();
gioDefaultProps = defaultClassLoader.getResourceAsStream("gio_default.properties");
prop.load(gioDefaultProps);
}

InputStream gioProps = classLoader.getResourceAsStream("gio.properties");
if (gioProps != null) {
Expand Down

0 comments on commit 6d9c88a

Please sign in to comment.