本文整理汇总了Java中io.grpc.internal.GrpcUtil.IS_RESTRICTED_APPENGINE属性的典型用法代码示例。如果您正苦于以下问题:Java GrpcUtil.IS_RESTRICTED_APPENGINE属性的具体用法?Java GrpcUtil.IS_RESTRICTED_APPENGINE怎么用?Java GrpcUtil.IS_RESTRICTED_APPENGINE使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类io.grpc.internal.GrpcUtil
的用法示例。
在下文中一共展示了GrpcUtil.IS_RESTRICTED_APPENGINE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
@Override
public void run() {
String threadName = Thread.currentThread().getName();
if (!GrpcUtil.IS_RESTRICTED_APPENGINE) {
Thread.currentThread().setName("OkHttpClientTransport");
}
try {
// Read until the underlying socket closes.
while (frameReader.nextFrame(this)) {
if (keepAliveManager != null) {
keepAliveManager.onDataReceived();
}
}
// frameReader.nextFrame() returns false when the underlying read encounters an IOException,
// it may be triggered by the socket closing, in such case, the startGoAway() will do
// nothing, otherwise, we finish all streams since it's a real IO issue.
startGoAway(0, ErrorCode.INTERNAL_ERROR,
Status.UNAVAILABLE.withDescription("End of stream or IOException"));
} catch (Throwable t) {
// TODO(madongfly): Send the exception message to the server.
startGoAway(
0,
ErrorCode.PROTOCOL_ERROR,
Status.UNAVAILABLE.withDescription("error in frame handler").withCause(t));
} finally {
try {
frameReader.close();
} catch (IOException ex) {
log.log(Level.INFO, "Exception closing frame reader", ex);
}
listener.transportTerminated();
if (!GrpcUtil.IS_RESTRICTED_APPENGINE) {
// Restore the original thread name.
Thread.currentThread().setName(threadName);
}
}
}
示例2: createSocketFactory
@VisibleForTesting
@Nullable
SSLSocketFactory createSocketFactory() {
switch (negotiationType) {
case TLS:
try {
if (sslSocketFactory == null) {
SSLContext sslContext;
if (GrpcUtil.IS_RESTRICTED_APPENGINE) {
// The following auth code circumvents the following AccessControlException:
// access denied ("java.util.PropertyPermission" "javax.net.ssl.keyStore" "read")
// Conscrypt will attempt to load the default KeyStore if a trust manager is not
// provided, which is forbidden on AppEngine
sslContext = SSLContext.getInstance("TLS", Platform.get().getProvider());
TrustManagerFactory trustManagerFactory =
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
trustManagerFactory.init((KeyStore) null);
sslContext.init(
null,
trustManagerFactory.getTrustManagers(),
// Use an algorithm that doesn't need /dev/urandom
SecureRandom.getInstance("SHA1PRNG", Platform.get().getProvider()));
} else {
sslContext = SSLContext.getInstance("Default", Platform.get().getProvider());
}
sslSocketFactory = sslContext.getSocketFactory();
}
return sslSocketFactory;
} catch (GeneralSecurityException gse) {
throw new RuntimeException("TLS Provider failure", gse);
}
case PLAINTEXT:
return null;
default:
throw new RuntimeException("Unknown negotiation type: " + negotiationType);
}
}
示例3: priority
@Override
public int priority() {
return (GrpcUtil.IS_RESTRICTED_APPENGINE || isAndroid()) ? 8 : 3;
}