Replace Hashing.{md5,sha1} with Hashing.murmur3_128
md5 and sha1 are deprecated in Guava 22. Where possible, replace them with the recommended alternatives. In cases where we need to keep using sha1 for compatibility, add a warning suppression with comment. Change-Id: I3f80d52ea4e299c2a7c86fbda25457814bff750c
This commit is contained in:
committed by
David Ostrovsky
parent
58087a18a0
commit
f4001aa356
@@ -133,7 +133,7 @@ public class HostPageServlet extends HttpServlet {
|
||||
String src = "gerrit_ui/gerrit_ui.nocache.js";
|
||||
try (InputStream in = servletContext.getResourceAsStream("/" + src)) {
|
||||
if (in != null) {
|
||||
Hasher md = Hashing.md5().newHasher();
|
||||
Hasher md = Hashing.murmur3_128().newHasher();
|
||||
byte[] buf = new byte[1024];
|
||||
int n;
|
||||
while ((n = in.read(buf)) > 0) {
|
||||
|
||||
@@ -312,7 +312,7 @@ public abstract class ResourceServlet extends HttpServlet {
|
||||
this.lastModified = checkNotNull(lastModified, "lastModified");
|
||||
this.contentType = checkNotNull(contentType, "contentType");
|
||||
this.raw = checkNotNull(raw, "raw");
|
||||
this.etag = Hashing.md5().hashBytes(raw).toString();
|
||||
this.etag = Hashing.murmur3_128().hashBytes(raw).toString();
|
||||
}
|
||||
|
||||
boolean isStale(Path p, ResourceServlet rs) throws IOException {
|
||||
|
||||
@@ -280,7 +280,7 @@ class LibraryDownloader {
|
||||
System.err.flush();
|
||||
return;
|
||||
}
|
||||
Hasher h = Hashing.sha1().newHasher();
|
||||
Hasher h = Hashing.murmur3_128().newHasher();
|
||||
try (InputStream in = Files.newInputStream(dst);
|
||||
OutputStream out = Funnels.asOutputStream(h)) {
|
||||
ByteStreams.copy(in, out);
|
||||
|
||||
@@ -96,6 +96,7 @@ public abstract class ExternalId implements Serializable {
|
||||
* Returns the SHA1 of the external ID that is used as note ID in the refs/meta/external-ids
|
||||
* notes branch.
|
||||
*/
|
||||
@SuppressWarnings("deprecation") // Use Hashing.sha1 for compatibility.
|
||||
public ObjectId sha1() {
|
||||
return ObjectId.fromRaw(Hashing.sha1().hashString(get(), UTF_8).asBytes());
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ChangeResource implements RestResource, HasETag {
|
||||
@Override
|
||||
public String getETag() {
|
||||
CurrentUser user = control.getUser();
|
||||
Hasher h = Hashing.md5().newHasher();
|
||||
Hasher h = Hashing.murmur3_128().newHasher();
|
||||
if (user.isIdentifiedUser()) {
|
||||
h.putString(starredChangesUtil.getObjectId(user.getAccountId(), getId()).name(), UTF_8);
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class FileContentUtil {
|
||||
// an attacker could upload a *.class file and have us send a ZIP
|
||||
// that can be invoked through an applet tag in the victim's browser.
|
||||
//
|
||||
Hasher h = Hashing.md5().newHasher();
|
||||
Hasher h = Hashing.murmur3_128().newHasher();
|
||||
byte[] buf = new byte[8];
|
||||
|
||||
NB.encodeInt64(buf, 0, TimeUtil.nowMs());
|
||||
|
||||
@@ -63,7 +63,7 @@ public class GetRevisionActions implements ETagView<RevisionResource> {
|
||||
|
||||
@Override
|
||||
public String getETag(RevisionResource rsrc) {
|
||||
Hasher h = Hashing.md5().newHasher();
|
||||
Hasher h = Hashing.murmur3_128().newHasher();
|
||||
CurrentUser user = rsrc.getControl().getUser();
|
||||
try {
|
||||
rsrc.getChangeResource().prepareETag(h, user);
|
||||
|
||||
@@ -745,7 +745,7 @@ public class PostReview
|
||||
comment.key.patchSetId,
|
||||
comment.lineNbr,
|
||||
Side.fromShort(comment.side),
|
||||
Hashing.sha1().hashString(comment.message, UTF_8),
|
||||
Hashing.murmur3_128().hashString(comment.message, UTF_8),
|
||||
comment.range);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ public class RequestId {
|
||||
private final String str;
|
||||
|
||||
private RequestId(String resourceId) {
|
||||
Hasher h = Hashing.sha1().newHasher();
|
||||
Hasher h = Hashing.murmur3_128().newHasher();
|
||||
h.putLong(Thread.currentThread().getId()).putUnencodedChars(MACHINE_ID);
|
||||
str =
|
||||
"["
|
||||
|
||||
Reference in New Issue
Block a user