File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed
cache/src/main/java/io/envoyproxy/controlplane/cache Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change 4
4
import com .google .common .hash .Hashing ;
5
5
import com .google .protobuf .Message ;
6
6
7
+ import java .nio .charset .StandardCharsets ;
8
+
7
9
@ AutoValue
8
10
public abstract class VersionedResource <T extends Message > {
9
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?
34
36
Hashing .sha256 ()
35
- .hashBytes ( resource . toByteArray () )
37
+ .hashString ( resourceHashCode ( resource ), StandardCharsets . UTF_8 )
36
38
.toString ()
37
39
);
38
40
}
39
41
42
+ private static <T extends Message > String resourceHashCode (T resource ) {
43
+ return resource .getClass () + "@" + resource .hashCode ();
44
+ }
45
+
40
46
/**
41
47
* Returns the resource.
42
48
*/
You can’t perform that action at this time.
0 commit comments