Skip to content

Commit 069b752

Browse files
authored
Fix the perf issue when debug idea (microsoft#42)
Fix the perf issue when debug idea (microsoft#42)
1 parent 435f925 commit 069b752

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

com.microsoft.java.debug.core/src/main/java/com/microsoft/java/debug/core/adapter/handler/StackTraceRequestHandler.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import java.util.Arrays;
1717
import java.util.List;
1818

19+
import org.apache.commons.lang3.StringUtils;
20+
1921
import com.microsoft.java.debug.core.DebugUtility;
2022
import com.microsoft.java.debug.core.adapter.AdapterUtils;
2123
import com.microsoft.java.debug.core.adapter.IDebugAdapterContext;
@@ -109,11 +111,13 @@ private Types.Source convertDebuggerSourceToClient(Location location, IDebugAdap
109111

110112
final String finalRelativeSourcePath = relativeSourcePath;
111113
// use a lru cache for better performance
112-
String uri = context.getSourceLookupCache().computeIfAbsent(fullyQualifiedName, key ->
113-
context.getProvider(ISourceLookUpProvider.class).getSourceFileURI(key, finalRelativeSourcePath)
114-
);
114+
String uri = context.getSourceLookupCache().computeIfAbsent(fullyQualifiedName, key -> {
115+
String fromProvider = context.getProvider(ISourceLookUpProvider.class).getSourceFileURI(key, finalRelativeSourcePath);
116+
// avoid return null which will cause the compute function executed again
117+
return StringUtils.isBlank(fromProvider) ? "" : fromProvider;
118+
});
115119

116-
if (uri != null) {
120+
if (!StringUtils.isBlank(uri)) {
117121
String clientPath = AdapterUtils.convertPath(uri, context.isDebuggerPathsAreUri(), context.isClientPathsAreUri());
118122
if (uri.startsWith("file:")) {
119123
return new Types.Source(sourceName, clientPath, 0);

0 commit comments

Comments
 (0)