Skip to content

Commit

Permalink
Coarsen deep hash code calculation for ObjectCodecRegistry: lambdas' …
Browse files Browse the repository at this point in the history
…suffixes are non-deterministic. The integer index before the '/' character should be deterministic, but doesn't seem to be.

PiperOrigin-RevId: 218918204
  • Loading branch information
janakdr authored and Copybara-Service committed Oct 26, 2018
1 parent df5fe4a commit 2290505
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,13 @@ private int deepHashCode() {
}

private static int hashClass(Class<?> clazz) {
if (LambdaCodec.isProbablyLambda(clazz)) {
String name = clazz.getName();
int indexOfLambda = name.lastIndexOf("$$Lambda$");
if (indexOfLambda > -1) {
return name.substring(0, indexOfLambda + 9).hashCode();
}
}
return clazz.getName().hashCode();
}
}

0 comments on commit 2290505

Please sign in to comment.