Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,22 @@ private static String getCurrentPlatformState() {
if (bundleContext == null) {
return ""; //$NON-NLS-1$
}
String ID = Arrays.stream(bundleContext.getBundles())
.map(bundle -> String.format("%d %s %s", bundle.getBundleId(), bundle.getSymbolicName(), //$NON-NLS-1$
bundle.getVersion()))
String state = Arrays.stream(bundleContext.getBundles())
.map(ContentDescriptionManager::toStateEntry)
.sorted().collect(Collectors.joining(System.lineSeparator()));
return hash(state);
}

private static String toStateEntry(Bundle bundle) {
return bundle.getBundleId() + " " + bundle.getSymbolicName() + " " + bundle.getVersion(); //$NON-NLS-1$ //$NON-NLS-2$
}

private static String hash(String value) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256"); //$NON-NLS-1$
return HexFormat.of().formatHex(digest.digest(ID.getBytes(StandardCharsets.UTF_8)));
return HexFormat.of().formatHex(digest.digest(value.getBytes(StandardCharsets.UTF_8)));
} catch (NoSuchAlgorithmException e) {
return Integer.toHexString(ID.hashCode());
return Integer.toHexString(value.hashCode());
}
}

Expand Down
Loading