From c6240c172de604c20c749adf2935eca8c9af1f10 Mon Sep 17 00:00:00 2001 From: Shawn Pearce Date: Thu, 13 Jun 2013 15:43:39 -0700 Subject: [PATCH] Replace InputSupplier with ByteSource in AddSshKey Guava has deprecated and will remove InputSupplier in a future release. Update calling code to use ByteSource instead. Change-Id: I577a995b0aa14ddc0bea3045344ae8703323eca2 --- .../gerrit/server/account/AddSshKey.java | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gerrit-server/src/main/java/com/google/gerrit/server/account/AddSshKey.java b/gerrit-server/src/main/java/com/google/gerrit/server/account/AddSshKey.java index 681bf3c76a..2cff009f4e 100644 --- a/gerrit-server/src/main/java/com/google/gerrit/server/account/AddSshKey.java +++ b/gerrit-server/src/main/java/com/google/gerrit/server/account/AddSshKey.java @@ -15,8 +15,7 @@ package com.google.gerrit.server.account; import com.google.common.base.Charsets; -import com.google.common.io.CharStreams; -import com.google.common.io.InputSupplier; +import com.google.common.io.ByteSource; import com.google.gerrit.common.errors.InvalidSshKeyException; import com.google.gerrit.extensions.restapi.AuthException; import com.google.gerrit.extensions.restapi.BadRequestException; @@ -77,15 +76,14 @@ public class AddSshKey implements RestModifyView { max = Math.max(max, k.getKey().get()); } - final InputStream in = input.raw.getInputStream(); - String sshPublicKey = - CharStreams.toString(CharStreams.newReaderSupplier( - new InputSupplier() { - @Override - public InputStream getInput() { - return in; - } - }, Charsets.UTF_8)); + final RawInput rawKey = input.raw; + String sshPublicKey = new ByteSource() { + @Override + public InputStream openStream() throws IOException { + return rawKey.getInputStream(); + } + }.asCharSource(Charsets.UTF_8).read(); + try { AccountSshKey sshKey = sshKeyCache.create(new AccountSshKey.Id(