core: fix floating-point number formatting Locale (#7473)

This commit is contained in:
ZHANG Dapeng 2020-10-28 17:23:57 -07:00 committed by GitHub
parent 80631db7a8
commit 654f7c3dc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View File

@ -17,6 +17,7 @@
package io.grpc;
import java.util.Arrays;
import java.util.Locale;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
@ -206,7 +207,7 @@ public final class Deadline implements Comparable<Deadline> {
}
buf.append(seconds);
if (nanos > 0) {
buf.append(String.format(".%09d", nanos));
buf.append(String.format(Locale.US, ".%09d", nanos));
}
buf.append("s from now");
if (ticker != SYSTEM_TICKER) {

View File

@ -54,6 +54,7 @@ import io.perfmark.PerfMark;
import io.perfmark.Tag;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.util.Locale;
import java.util.concurrent.CancellationException;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
@ -441,7 +442,7 @@ final class ClientCallImpl<ReqT, RespT> extends ClientCall<ReqT, RespT> {
buf.append('-');
}
buf.append(seconds);
buf.append(String.format(".%09d", nanos));
buf.append(String.format(Locale.US, ".%09d", nanos));
buf.append("s. ");
buf.append(insight);
stream.cancel(DEADLINE_EXCEEDED.augmentDescription(buf.toString()));

View File

@ -30,6 +30,7 @@ import io.grpc.Metadata;
import io.grpc.Status;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
@ -117,7 +118,7 @@ class DelayedClientCall<ReqT, RespT> extends ClientCall<ReqT, RespT> {
buf.append("Deadline exceeded after ");
}
buf.append(seconds);
buf.append(String.format(".%09d", nanos));
buf.append(String.format(Locale.US, ".%09d", nanos));
buf.append("s. ");
/** Cancels the call if deadline exceeded prior to the real call being set. */
class DeadlineExceededRunnable implements Runnable {