Skip to content

Commit

Permalink
fix: load remote jar url to compatible with remote loader util (#360)
Browse files Browse the repository at this point in the history
  • Loading branch information
QizhengMo authored Oct 24, 2024
1 parent 6c032ea commit e7411fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
4 changes: 2 additions & 2 deletions arex-schedule-web-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<parent>
<artifactId>arex-schedule-parent</artifactId>
<groupId>com.arextest</groupId>
<version>2.0.1</version>
<version>2.0.2</version>
</parent>

<profiles>
Expand Down Expand Up @@ -337,5 +337,5 @@
</properties>
</profile>
</profiles>
<version>2.0.1</version>
<version>2.0.2</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
Expand All @@ -33,26 +32,18 @@
public class ReplaySenderConfiguration {
@Value("${replay.sender.extension.jarPath}")
private String jarFilePath;

private static final String LOCAL_INVOKER_PATH = "lib/dubboInvoker.jar";
private static final String NEW_INVOKER_PATH = "dubboInvoker.jar";
private static final List<String> remoteProtocol = Arrays.asList("http", "https", "ftp", "sftp", "nfs");

@Bean("dubboInvokerLoader")
@ConditionalOnProperty(name = "replay.sender.extension.switch", havingValue = "true")
public RemoteJarClassLoader dubboInvokerLoader() {
try {
URL classPathResource;
if (StringUtils.isNotBlank(jarFilePath)) {
if (isRemote(jarFilePath)) {
classPathResource = new URL(jarFilePath);
} else {
classPathResource = new File(jarFilePath).toURI().toURL();
}
return RemoteJarLoaderUtils.loadJar(jarFilePath);
} else {
classPathResource = loadLocalInvokerJar();
return RemoteJarLoaderUtils.loadJar(loadLocalInvokerJar().getPath());
}
return RemoteJarLoaderUtils.loadJar(classPathResource.getPath());
} catch (Throwable t) {
LOGGER.error("Load invoker jar failed, application startup blocked", t);
}
Expand Down Expand Up @@ -90,15 +81,6 @@ public ReplaySenderFactory replaySenderFactory(List<ReplaySender> senders) {
return new ReplaySenderFactory(senders);
}

private boolean isRemote(String path) {
for (String protocol : remoteProtocol) {
if (path.startsWith(protocol)) {
return true;
}
}
return false;
}

private void inputStreamToFile(InputStream inputStream, String filePath) throws IOException {
File file = new File(filePath);
try (FileOutputStream fos = new FileOutputStream(file)) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -317,5 +317,5 @@
<url>https://github.com/arextest/arex-replay-schedule</url>
</scm>
<url>https://github.com/arextest/arex-replay-schedule</url>
<version>2.0.1</version>
<version>2.0.2</version>
</project>

0 comments on commit e7411fa

Please sign in to comment.