mirror of https://github.com/grpc/grpc-java.git
Don't use switch on string, for Java 6 compatibility
------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=75322297
This commit is contained in:
parent
57bfc6a01d
commit
029f0d22f8
|
|
@ -263,26 +263,29 @@ public class Http2Negotiator {
|
||||||
@Override
|
@Override
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
String methodName = method.getName();
|
String methodName = method.getName();
|
||||||
switch (methodName) {
|
if ("supports".equals(methodName)) {
|
||||||
case "supports":
|
|
||||||
// both
|
// both
|
||||||
return true;
|
return true;
|
||||||
case "unsupported":
|
}
|
||||||
|
if ("unsupported".equals(methodName)) {
|
||||||
// both
|
// both
|
||||||
removeMethod.invoke(null, engine);
|
removeMethod.invoke(null, engine);
|
||||||
protocolNegotiated.setException(new IllegalStateException(
|
protocolNegotiated.setException(new IllegalStateException(
|
||||||
"ALPN/NPN protocol " + HTTP_VERSION_NAME + " not supported by server"));
|
"ALPN/NPN protocol " + HTTP_VERSION_NAME + " not supported by server"));
|
||||||
return null;
|
return null;
|
||||||
case "protocols":
|
}
|
||||||
|
if ("protocols".equals(methodName)) {
|
||||||
// ALPN only
|
// ALPN only
|
||||||
return ImmutableList.of(HTTP_VERSION_NAME);
|
return ImmutableList.of(HTTP_VERSION_NAME);
|
||||||
case "selected":
|
}
|
||||||
|
if ("selected".equals(methodName)) {
|
||||||
// ALPN only
|
// ALPN only
|
||||||
// Only 'supports' one protocol so we know what was selected.
|
// Only 'supports' one protocol so we know what was selected.
|
||||||
removeMethod.invoke(null, engine);
|
removeMethod.invoke(null, engine);
|
||||||
protocolNegotiated.set(null);
|
protocolNegotiated.set(null);
|
||||||
return null;
|
return null;
|
||||||
case "selectProtocol":
|
}
|
||||||
|
if ("selectProtocol".equals(methodName)) {
|
||||||
// NPN only
|
// NPN only
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> names = (List<String>) args[0];
|
List<String> names = (List<String>) args[0];
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue