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
This commit is contained in:
Shawn Pearce
2013-06-13 15:43:39 -07:00
parent f85c67af50
commit c6240c172d

View File

@@ -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<AccountResource, Input> {
max = Math.max(max, k.getKey().get());
}
final InputStream in = input.raw.getInputStream();
String sshPublicKey =
CharStreams.toString(CharStreams.newReaderSupplier(
new InputSupplier<InputStream>() {
@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(