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:
@@ -15,8 +15,7 @@
|
|||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.google.common.io.CharStreams;
|
import com.google.common.io.ByteSource;
|
||||||
import com.google.common.io.InputSupplier;
|
|
||||||
import com.google.gerrit.common.errors.InvalidSshKeyException;
|
import com.google.gerrit.common.errors.InvalidSshKeyException;
|
||||||
import com.google.gerrit.extensions.restapi.AuthException;
|
import com.google.gerrit.extensions.restapi.AuthException;
|
||||||
import com.google.gerrit.extensions.restapi.BadRequestException;
|
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());
|
max = Math.max(max, k.getKey().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
final InputStream in = input.raw.getInputStream();
|
final RawInput rawKey = input.raw;
|
||||||
String sshPublicKey =
|
String sshPublicKey = new ByteSource() {
|
||||||
CharStreams.toString(CharStreams.newReaderSupplier(
|
@Override
|
||||||
new InputSupplier<InputStream>() {
|
public InputStream openStream() throws IOException {
|
||||||
@Override
|
return rawKey.getInputStream();
|
||||||
public InputStream getInput() {
|
}
|
||||||
return in;
|
}.asCharSource(Charsets.UTF_8).read();
|
||||||
}
|
|
||||||
}, Charsets.UTF_8));
|
|
||||||
try {
|
try {
|
||||||
AccountSshKey sshKey =
|
AccountSshKey sshKey =
|
||||||
sshKeyCache.create(new AccountSshKey.Id(
|
sshKeyCache.create(new AccountSshKey.Id(
|
||||||
|
Reference in New Issue
Block a user