Skip to content

Commit bccb480

Browse files
switch sha256 to calculate temp file name (#592)
1 parent 54058b9 commit bccb480

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public static synchronized Path generateClasspathJar(String[] classPaths) throws
9595
// In jar manifest, the absolute path C:\a.jar should be converted to the url style file:///C:/a.jar
9696
String classpathValue = String.join(" ", classpathUrls);
9797
attributes.put(Attributes.Name.CLASS_PATH, classpathValue);
98-
String baseName = "cp_" + getMd5(classpathValue);
98+
String baseName = "cp_" + getSha256(classpathValue);
9999
cleanupTempFiles(baseName, ".jar");
100100
Path tempfile = createTempFile(baseName, ".jar");
101101
JarOutputStream jar = new JarOutputStream(new FileOutputStream(tempfile.toFile()), manifest);
@@ -127,7 +127,7 @@ public static synchronized Path generateArgfile(String vmArgs, String[] classPat
127127
}
128128

129129
argfile = argfile.replace("\\", "\\\\");
130-
String baseName = "cp_" + getMd5(argfile);
130+
String baseName = "cp_" + getSha256(argfile);
131131
cleanupTempFiles(baseName, ".argfile");
132132
Path tempfile = createTempFile(baseName, ".argfile");
133133
Files.writeString(tempfile, argfile, encoding);
@@ -364,12 +364,15 @@ private static Path createTempFile(String baseName, String suffix) throws IOExce
364364
}
365365
}
366366

367-
private static String getMd5(String input) {
367+
private static String getSha256(String input) {
368368
try {
369-
MessageDigest md = MessageDigest.getInstance("MD5");
369+
MessageDigest md = MessageDigest.getInstance("SHA-256");
370370
byte[] messageDigest = md.digest(input.getBytes());
371-
BigInteger md5 = new BigInteger(1, messageDigest);
372-
return md5.toString(Character.MAX_RADIX);
371+
// Use only first 16 bytes to keep filename shorter
372+
byte[] truncated = new byte[16];
373+
System.arraycopy(messageDigest, 0, truncated, 0, 16);
374+
BigInteger hash = new BigInteger(1, truncated);
375+
return hash.toString(Character.MAX_RADIX);
373376
} catch (NoSuchAlgorithmException e) {
374377
return Integer.toString(input.hashCode(), Character.MAX_RADIX);
375378
}

com.microsoft.java.debug.target/com.microsoft.java.debug.tp.target

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<locations>
33
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
44
<unit id="org.eclipse.platform.feature.group" version="0.0.0"/>
5-
<repository location="https://download.eclipse.org/eclipse/updates/4.36-I-builds/"/>
5+
<repository location="https://download.eclipse.org/eclipse/updates/4.37-I-builds/"/>
66
</location>
77
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="planner" includeSource="true" type="InstallableUnit">
88
<unit id="org.eclipse.jdt.ls.core" version="0.0.0"/>

0 commit comments

Comments
 (0)