Skip to content

Commit d9811a0

Browse files
committed
fix ArthasBanner latestVersion() block. #3021
1 parent b099051 commit d9811a0

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

core/src/main/java/com/taobao/arthas/core/util/ArthasBanner.java

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,29 @@ public static String welcome(Map<String, String> infos) {
139139
}
140140

141141
static String latestVersion() {
142+
final String[] version = { "" };
143+
Thread thread = new Thread(new Runnable() {
144+
@Override
145+
public void run() {
146+
try {
147+
URLConnection urlConnection = openURLConnection(ARTHAS_LATEST_VERSIONS_URL);
148+
InputStream inputStream = urlConnection.getInputStream();
149+
version[0] = com.taobao.arthas.common.IOUtils.toString(inputStream).trim();
150+
} catch (Throwable e) {
151+
logger.debug("get latest version error", e);
152+
}
153+
}
154+
});
155+
156+
thread.setDaemon(true);
157+
thread.start();
142158
try {
143-
URLConnection urlConnection = openURLConnection(ARTHAS_LATEST_VERSIONS_URL);
144-
InputStream inputStream = urlConnection.getInputStream();
145-
return com.taobao.arthas.common.IOUtils.toString(inputStream).trim();
159+
thread.join(2000); // Wait up to 2 seconds for the version check
146160
} catch (Throwable e) {
147-
// ignore
161+
// Ignore
148162
}
149-
return "";
163+
164+
return version[0];
150165
}
151166

152167
/**

0 commit comments

Comments
 (0)