We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 608c21c commit 6136bf2Copy full SHA for 6136bf2
1 file changed
cache/src/main/java/io/envoyproxy/controlplane/cache/VersionedResource.java
@@ -4,6 +4,8 @@
4
import com.google.common.hash.Hashing;
5
import com.google.protobuf.Message;
6
7
+import java.nio.charset.StandardCharsets;
8
+
9
@AutoValue
10
public abstract class VersionedResource<T extends Message> {
11
@@ -32,11 +34,15 @@ public static <T extends Message> VersionedResource<T> create(T resource) {
32
34
resource,
33
35
// todo: is this a stable hash?
36
Hashing.sha256()
- .hashBytes(resource.toByteArray())
37
+ .hashString(resourceHashCode(resource), StandardCharsets.UTF_8)
38
.toString()
39
);
40
}
41
42
+ private static <T extends Message> String resourceHashCode(T resource) {
43
+ return resource.getClass() + "@" + resource.hashCode();
44
+ }
45
46
/**
47
* Returns the resource.
48
*/
0 commit comments