Search in sources :

Example 1 with ManagedChannelBuilder

use of io.grpc.ManagedChannelBuilder in project pinpoint by naver.

the class BuilderUtils method getUsePlainText.

private static Call getUsePlainText() {
    final Class<ManagedChannelBuilder> builderClass = ManagedChannelBuilder.class;
    final Method oldUsePlaintext = getMethod(builderClass, "usePlaintext");
    if (oldUsePlaintext != null) {
        return new Call<ManagedChannelBuilder<?>>() {

            @Override
            public void call(ManagedChannelBuilder<?> target) {
                try {
                    oldUsePlaintext.invoke(target);
                } catch (Exception e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
            }
        };
    }
    final Method newUsePlaintext = getMethod(builderClass, "usePlaintext", boolean.class);
    if (newUsePlaintext != null) {
        return new Call<ManagedChannelBuilder<?>>() {

            @Override
            public void call(ManagedChannelBuilder<?> target) {
                try {
                    newUsePlaintext.invoke(target, true);
                } catch (Exception e) {
                    throw new RuntimeException(e.getMessage(), e);
                }
            }
        };
    }
    throw new UnsupportedOperationException("usePlaintext method not found");
}
Also used : ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Method(java.lang.reflect.Method)

Example 2 with ManagedChannelBuilder

use of io.grpc.ManagedChannelBuilder in project pinpoint by naver.

the class BuilderUtilsTest method usePlainText.

@Test
public void usePlainText() {
    ManagedChannelBuilder mock = mock(ManagedChannelBuilder.class);
    BuilderUtils.usePlainText(mock);
}
Also used : ManagedChannelBuilder(io.grpc.ManagedChannelBuilder) Test(org.junit.Test)

Aggregations

ManagedChannelBuilder (io.grpc.ManagedChannelBuilder)2 Method (java.lang.reflect.Method)1 Test (org.junit.Test)1