Use Java 7 StandardCharsets instead of Guava Charsets
Replace with static imports since the class name is so much longer. Change-Id: If2cdede62a0977db05db69b4c9ec88bd980e011f
This commit is contained in:
parent
c6f7459d92
commit
68a55b9074
@ -14,9 +14,10 @@
|
|||||||
|
|
||||||
package com.google.gerrit.httpd.restapi;
|
package com.google.gerrit.httpd.restapi;
|
||||||
|
|
||||||
import static com.google.common.base.Charsets.UTF_8;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
import static java.math.RoundingMode.CEILING;
|
import static java.math.RoundingMode.CEILING;
|
||||||
|
import static java.nio.charset.StandardCharsets.ISO_8859_1;
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
import static javax.servlet.http.HttpServletResponse.SC_BAD_REQUEST;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_CONFLICT;
|
import static javax.servlet.http.HttpServletResponse.SC_CONFLICT;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_CREATED;
|
import static javax.servlet.http.HttpServletResponse.SC_CREATED;
|
||||||
@ -28,7 +29,6 @@ import static javax.servlet.http.HttpServletResponse.SC_NOT_MODIFIED;
|
|||||||
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
import static javax.servlet.http.HttpServletResponse.SC_OK;
|
||||||
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
|
import static javax.servlet.http.HttpServletResponse.SC_PRECONDITION_FAILED;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@ -737,7 +737,7 @@ public class RestApiServlet extends HttpServlet {
|
|||||||
@Override
|
@Override
|
||||||
public void writeTo(OutputStream out) throws IOException {
|
public void writeTo(OutputStream out) throws IOException {
|
||||||
OutputStream e = BaseEncoding.base64().encodingStream(
|
OutputStream e = BaseEncoding.base64().encodingStream(
|
||||||
new OutputStreamWriter(out, Charsets.ISO_8859_1));
|
new OutputStreamWriter(out, ISO_8859_1));
|
||||||
src.writeTo(e);
|
src.writeTo(e);
|
||||||
e.flush();
|
e.flush();
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ public class RestApiServlet extends HttpServlet {
|
|||||||
int max = 4 * IntMath.divide((int) bin.getContentLength(), 3, CEILING);
|
int max = 4 * IntMath.divide((int) bin.getContentLength(), 3, CEILING);
|
||||||
TemporaryBuffer.Heap buf = heap(max);
|
TemporaryBuffer.Heap buf = heap(max);
|
||||||
OutputStream encoded = BaseEncoding.base64().encodingStream(
|
OutputStream encoded = BaseEncoding.base64().encodingStream(
|
||||||
new OutputStreamWriter(buf, Charsets.ISO_8859_1));
|
new OutputStreamWriter(buf, ISO_8859_1));
|
||||||
bin.writeTo(encoded);
|
bin.writeTo(encoded);
|
||||||
encoded.close();
|
encoded.close();
|
||||||
return asBinaryResult(buf);
|
return asBinaryResult(buf);
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.account;
|
package com.google.gerrit.server.account;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.io.ByteSource;
|
import com.google.common.io.ByteSource;
|
||||||
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;
|
||||||
@ -79,7 +80,7 @@ public class AddSshKey implements RestModifyView<AccountResource, Input> {
|
|||||||
public InputStream openStream() throws IOException {
|
public InputStream openStream() throws IOException {
|
||||||
return rawKey.getInputStream();
|
return rawKey.getInputStream();
|
||||||
}
|
}
|
||||||
}.asCharSource(Charsets.UTF_8).read();
|
}.asCharSource(UTF_8).read();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
AccountSshKey sshKey =
|
AccountSshKey sshKey =
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import static com.google.common.base.Charsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.gerrit.extensions.restapi.BinaryResult;
|
import com.google.gerrit.extensions.restapi.BinaryResult;
|
||||||
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
import com.google.gerrit.extensions.restapi.ResourceConflictException;
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
@ -98,7 +99,7 @@ public class TestSubmitRule implements RestModifyView<RevisionResource, Input> {
|
|||||||
"locate_submit_filter", "filter_submit_results",
|
"locate_submit_filter", "filter_submit_results",
|
||||||
input.filters == Filters.SKIP,
|
input.filters == Filters.SKIP,
|
||||||
input.rule != null
|
input.rule != null
|
||||||
? new ByteArrayInputStream(input.rule.getBytes(Charsets.UTF_8))
|
? new ByteArrayInputStream(input.rule.getBytes(UTF_8))
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
List<Term> results;
|
List<Term> results;
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.change;
|
package com.google.gerrit.server.change;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
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;
|
||||||
@ -78,7 +79,7 @@ public class TestSubmitType implements RestModifyView<RevisionResource, Input> {
|
|||||||
"locate_submit_type_filter", "filter_submit_type_results",
|
"locate_submit_type_filter", "filter_submit_type_results",
|
||||||
input.filters == Filters.SKIP,
|
input.filters == Filters.SKIP,
|
||||||
input.rule != null
|
input.rule != null
|
||||||
? new ByteArrayInputStream(input.rule.getBytes(Charsets.UTF_8))
|
? new ByteArrayInputStream(input.rule.getBytes(UTF_8))
|
||||||
: null);
|
: null);
|
||||||
|
|
||||||
List<Term> results;
|
List<Term> results;
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.mail;
|
package com.google.gerrit.server.mail;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.ParameterizedString;
|
import com.google.gerrit.common.data.ParameterizedString;
|
||||||
import com.google.gerrit.reviewdb.client.Account;
|
import com.google.gerrit.reviewdb.client.Account;
|
||||||
import com.google.gerrit.server.GerritPersonIdent;
|
import com.google.gerrit.server.GerritPersonIdent;
|
||||||
@ -179,7 +180,7 @@ public class FromAddressGeneratorProvider implements
|
|||||||
private static String hashOf(String data) {
|
private static String hashOf(String data) {
|
||||||
try {
|
try {
|
||||||
MessageDigest hash = MessageDigest.getInstance("MD5");
|
MessageDigest hash = MessageDigest.getInstance("MD5");
|
||||||
byte[] bytes = hash.digest(data.getBytes(Charsets.UTF_8));
|
byte[] bytes = hash.digest(data.getBytes(UTF_8));
|
||||||
return Base64.encodeBase64URLSafeString(bytes);
|
return Base64.encodeBase64URLSafeString(bytes);
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
throw new RuntimeException("No MD5 available", e);
|
throw new RuntimeException("No MD5 available", e);
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.gerrit.common.data.GarbageCollectionResult;
|
import com.google.gerrit.common.data.GarbageCollectionResult;
|
||||||
import com.google.gerrit.common.data.GlobalCapability;
|
import com.google.gerrit.common.data.GlobalCapability;
|
||||||
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
import com.google.gerrit.extensions.annotations.RequiresCapability;
|
||||||
@ -58,7 +59,7 @@ public class GarbageCollect implements RestModifyView<ProjectResource, Input>,
|
|||||||
@Override
|
@Override
|
||||||
public void writeTo(OutputStream out) throws IOException {
|
public void writeTo(OutputStream out) throws IOException {
|
||||||
PrintWriter writer = new PrintWriter(
|
PrintWriter writer = new PrintWriter(
|
||||||
new OutputStreamWriter(out, Charsets.UTF_8)) {
|
new OutputStreamWriter(out, UTF_8)) {
|
||||||
@Override
|
@Override
|
||||||
public void println() {
|
public void println() {
|
||||||
write('\n');
|
write('\n');
|
||||||
@ -94,7 +95,7 @@ public class GarbageCollect implements RestModifyView<ProjectResource, Input>,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.setContentType("text/plain")
|
}.setContentType("text/plain")
|
||||||
.setCharacterEncoding(Charsets.UTF_8.name())
|
.setCharacterEncoding(UTF_8.name())
|
||||||
.disableGzip();
|
.disableGzip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.project;
|
package com.google.gerrit.server.project;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Predicate;
|
import com.google.common.base.Predicate;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
@ -30,8 +31,8 @@ import com.google.gerrit.common.data.Permission;
|
|||||||
import com.google.gerrit.common.data.PermissionRule;
|
import com.google.gerrit.common.data.PermissionRule;
|
||||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.reviewdb.client.RefNames;
|
|
||||||
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
import com.google.gerrit.reviewdb.client.Project.InheritableBoolean;
|
||||||
|
import com.google.gerrit.reviewdb.client.RefNames;
|
||||||
import com.google.gerrit.rules.PrologEnvironment;
|
import com.google.gerrit.rules.PrologEnvironment;
|
||||||
import com.google.gerrit.rules.RulesCache;
|
import com.google.gerrit.rules.RulesCache;
|
||||||
import com.google.gerrit.server.CurrentUser;
|
import com.google.gerrit.server.CurrentUser;
|
||||||
@ -482,7 +483,7 @@ public class ProjectState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String readFile(File f) throws IOException {
|
private String readFile(File f) throws IOException {
|
||||||
return f.exists() ? Files.toString(f, Charsets.UTF_8) : null;
|
return f.exists() ? Files.toString(f, UTF_8) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getInheritableBoolean(Function<Project, InheritableBoolean> func) {
|
private boolean getInheritableBoolean(Function<Project, InheritableBoolean> func) {
|
||||||
|
@ -14,14 +14,13 @@
|
|||||||
|
|
||||||
package com.google.gerrit.server.query.change;
|
package com.google.gerrit.server.query.change;
|
||||||
|
|
||||||
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
import static java.util.concurrent.TimeUnit.DAYS;
|
import static java.util.concurrent.TimeUnit.DAYS;
|
||||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||||
import static java.util.concurrent.TimeUnit.MINUTES;
|
import static java.util.concurrent.TimeUnit.MINUTES;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import com.google.common.base.Charsets;
|
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
@ -681,10 +680,10 @@ public abstract class AbstractQueryChangesTest {
|
|||||||
if (key == null) {
|
if (key == null) {
|
||||||
key = "I" + Hashing.sha1().newHasher()
|
key = "I" + Hashing.sha1().newHasher()
|
||||||
.putInt(id.get())
|
.putInt(id.get())
|
||||||
.putString(project.get(), Charsets.UTF_8)
|
.putString(project.get(), UTF_8)
|
||||||
.putString(commit.name(), Charsets.UTF_8)
|
.putString(commit.name(), UTF_8)
|
||||||
.putInt(ownerId.get())
|
.putInt(ownerId.get())
|
||||||
.putString(branch, Charsets.UTF_8)
|
.putString(branch, UTF_8)
|
||||||
.hash()
|
.hash()
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user