Skip to content
Open
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@
@Documented
@Retention(RUNTIME)
@Target({METHOD, CONSTRUCTOR})
public @interface ThriftConstructor
{
}
public @interface ThriftConstructor {}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
@Documented
@Retention(RUNTIME)
@Target(FIELD)
public @interface ThriftEnumUnknownValue
{
}
public @interface ThriftEnumUnknownValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@
@Documented
@Retention(RUNTIME)
@Target(METHOD)
public @interface ThriftEnumValue
{
}
public @interface ThriftEnumValue {}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,6 @@ enum Requiredness
* when this happens). As such, primitive types should be replaced with boxed types, so that
* null is always a possibility.
*/
OPTIONAL
OPTIONAL,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
@Documented
@Retention(RUNTIME)
@Target({METHOD, FIELD})
public @interface ThriftUnionId
{
}
public @interface ThriftUnionId {}
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public DriftClientFactory(
AddressSelector<? extends Address> addressSelector,
ExceptionClassifier exceptionClassifier)
{
this(
codecManager,
this(codecManager,
() -> invokerFactory.createMethodInvoker(null),
addressSelector,
exceptionClassifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public DriftClientFactoryManager(ThriftCodecManager codecManager, MethodInvokerF
this(codecManager, methodInvokerFactory, new NullMethodInvocationStatsFactory());
}

public DriftClientFactoryManager(ThriftCodecManager codecManager,
public DriftClientFactoryManager(
ThriftCodecManager codecManager,
MethodInvokerFactory<I> methodInvokerFactory,
MethodInvocationStatsFactory methodInvocationStatsFactory)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ public Object invoke(Object proxy, Method method, Object[] args)
private static ListenableFuture<Object> unwrapUserException(ListenableFuture<Object> future)
{
SettableFuture<Object> result = SettableFuture.create();
Futures.addCallback(future, new FutureCallback<Object>()
Futures.addCallback(
future,
new FutureCallback<Object>()
{
@Override
public void onSuccess(Object value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ private synchronized void invoke(A address)
stat.recordResult(invocationStartTime, result);
currentTask = result;

Futures.addCallback(result, new FutureCallback<Object>()
Futures.addCallback(
result,
new FutureCallback<Object>()
{
@Override
public void onSuccess(Object result)
Expand Down Expand Up @@ -267,7 +269,8 @@ else if (exceptionClassification.getHostStatus() == DOWN || exceptionClassificat

// backoff before next invocation
Duration backoffDelay = retryPolicy.getBackoffDelay(invocationAttempts);
log.debug("Failed invocation of %s with attempt %s, will retry in %s (overloadedRejects: %s). Exception: %s",
log.debug(
"Failed invocation of %s with attempt %s, will retry in %s (overloadedRejects: %s). Exception: %s",
metadata.getName(),
invocationAttempts,
backoffDelay,
Expand All @@ -286,7 +289,9 @@ private synchronized void schedule(Duration timeout, Runnable task)
try {
ListenableFuture<?> delay = invoker.delay(timeout);
currentTask = delay;
Futures.addCallback(delay, new FutureCallback<Object>()
Futures.addCallback(
delay,
new FutureCallback<Object>()
{
@Override
public void onSuccess(Object result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

public interface ExceptionClassifier
{
ExceptionClassifier NORMAL_RESULT = throwable -> NORMAL_EXCEPTION;
ExceptionClassifier NORMAL_RESULT = _ -> NORMAL_EXCEPTION;

static ExceptionClassifier mergeExceptionClassifiers(Iterable<? extends ExceptionClassifier> classifiers)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ public class RetryPolicy

public RetryPolicy(DriftClientConfig config, ExceptionClassifier exceptionClassifier)
{
this(
config.getMaxRetries(),
this(config.getMaxRetries(),
config.getMinBackoffDelay(),
config.getMaxBackoffDelay(),
config.getBackoffScaleFactor(),
config.getMaxRetryTime(),
exceptionClassifier);
}

public RetryPolicy(int maxRetries,
public RetryPolicy(
int maxRetries,
Duration minBackoffDelay,
Duration maxBackoffDelay,
double backoffScaleFactor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,4 @@
@Target({FIELD, PARAMETER, METHOD})
@Retention(RUNTIME)
@BindingAnnotation
public @interface DefaultClient
{
}
public @interface DefaultClient {}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static MethodInvocationFilterBinder staticFilterBinder(MethodInvocationFilter...

static MethodInvocationFilterBinder staticFilterBinder(List<MethodInvocationFilter> filters)
{
return (filterMultibinder, binder, annotation, prefix) -> {
return (filterMultibinder, _, _, _) -> {
for (MethodInvocationFilter filter : filters) {
filterMultibinder.addBinding().toInstance(filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public synchronized MethodInvocationStat getStat(ThriftServiceMetadata serviceMe
objectNameBuilder.withProperty("method", metadata.getName());
String objectName = objectNameBuilder.build();

return stats.computeIfAbsent(objectName, name -> {
return stats.computeIfAbsent(objectName, _ -> {
JmxMethodInvocationStat stat = new JmxMethodInvocationStat(metadata.getName());
exporter.export(objectName, stat);
return stat;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public MockMethodInvoker(Function<InvokeRequest, ListenableFuture<Object>> resul

public MockMethodInvoker(Supplier<ListenableFuture<Object>> resultsSupplier, TestingTicker ticker)
{
this(request -> resultsSupplier.get(), ticker);
this(_ -> resultsSupplier.get(), ticker);
}

private MockMethodInvoker(Function<InvokeRequest, ListenableFuture<Object>> resultsSupplier, TestingTicker ticker)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ public void testGuiceClient()
DriftClient<Client> driftClient = injector.getInstance(DEFAULT_CLIENT_KEY);
assertSame(injector.getInstance(DEFAULT_CLIENT_KEY), driftClient);
Client client = driftClient.get(ADDRESS_SELECTION_CONTEXT, HEADERS);
testClient(resultsSupplier,
testClient(
resultsSupplier,
ImmutableList.of(invokerFactory.getMethodInvoker()),
ImmutableList.of(globalClassifierOne, globalClassifierTwo, clientClassifier),
statsFactory,
Expand All @@ -178,7 +179,8 @@ public void testGuiceClient()
assertSame(injector.getInstance(CUSTOM_CLIENT_KEY), customDriftClient);
assertNotSame(driftClient, customDriftClient);
Client customClient = customDriftClient.get(ADDRESS_SELECTION_CONTEXT, HEADERS);
testClient(resultsSupplier,
testClient(
resultsSupplier,
ImmutableList.of(invokerFactory.getMethodInvoker()),
ImmutableList.of(globalClassifierOne, globalClassifierTwo, customClientClassifier),
statsFactory,
Expand Down Expand Up @@ -243,7 +245,8 @@ public void testGuiceClientFilter()
DriftClient<Client> driftClient = injector.getInstance(DEFAULT_CLIENT_KEY);
assertSame(injector.getInstance(DEFAULT_CLIENT_KEY), driftClient);
Client client = driftClient.get(ADDRESS_SELECTION_CONTEXT, HEADERS);
testClient(resultsSupplier,
testClient(
resultsSupplier,
ImmutableList.of(passThroughFilter, shortCircuitFilter),
ImmutableList.of(globalClassifierOne, globalClassifierTwo, clientClassifier),
statsFactory,
Expand All @@ -254,7 +257,8 @@ public void testGuiceClientFilter()
assertSame(injector.getInstance(CUSTOM_CLIENT_KEY), customDriftClient);
assertNotSame(driftClient, customDriftClient);
Client customClient = customDriftClient.get(ADDRESS_SELECTION_CONTEXT, HEADERS);
testClient(resultsSupplier,
testClient(
resultsSupplier,
ImmutableList.of(passThroughFilter, shortCircuitFilter),
ImmutableList.of(globalClassifierOne, globalClassifierTwo, customClientClassifier),
statsFactory,
Expand Down Expand Up @@ -506,14 +510,10 @@ String testHeader(@ThriftHeader("headerA") String firstHeader, int id, @ThriftHe

@ThriftStruct
public static class ClientException
extends Exception
{
}
extends Exception {}

private static class UnknownException
extends Exception
{
}
extends Exception {}

private static class TestingExceptionClassifier
implements ExceptionClassifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ private static void testConnectionFailedDelay(boolean overloaded, int numberOfAd
}
}

MockMethodInvoker invoker = new MockMethodInvoker(request -> immediateFailedFuture(createClassifiedException(true, overloaded ? OVERLOADED : DOWN)));
MockMethodInvoker invoker = new MockMethodInvoker(_ -> immediateFailedFuture(createClassifiedException(true, overloaded ? OVERLOADED : DOWN)));
DriftMethodInvocation<?> methodInvocation = createDriftMethodInvocation(
new RetryPolicy(new DriftClientConfig(), new TestingExceptionClassifier()),
new TestingMethodInvocationStat(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ public void testProvidedResult()

private static Optional<Boolean> classify(Optional<Boolean> classifierResult, Optional<Boolean> providedResult)
{
return new RetryPolicy(new DriftClientConfig(), classifier -> new ExceptionClassification(classifierResult, NORMAL))
return new RetryPolicy(new DriftClientConfig(), _ -> new ExceptionClassification(classifierResult, NORMAL))
.classifyException(new DriftApplicationException(new TestingUserException(), providedResult), true).isRetry();
}

private static class TestingUserException
extends Exception
{}
extends Exception {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public TestingMethodInvocationStat getStat(String serviceName, Optional<String>
@Override
public TestingMethodInvocationStat getStat(ThriftServiceMetadata serviceMetadata, Optional<String> qualifier, MethodMetadata metadata)
{
return stats.computeIfAbsent(new Key(serviceMetadata.getName(), qualifier, metadata.getName()), key -> new TestingMethodInvocationStat());
return stats.computeIfAbsent(new Key(serviceMetadata.getName(), qualifier, metadata.getName()), _ -> new TestingMethodInvocationStat());
}

private static class Key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
@Target({METHOD, CONSTRUCTOR, FIELD, PARAMETER})
@Retention(RUNTIME)
@BindingAnnotation
public @interface InternalThriftCodec
{
}
public @interface InternalThriftCodec {}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,4 @@
@Target({METHOD, CONSTRUCTOR, FIELD, PARAMETER})
@Retention(RUNTIME)
@BindingAnnotation
public @interface ForCompiler
{
}
public @interface ForCompiler {}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
@Immutable
public final class DefaultJavaCoercions
{
private DefaultJavaCoercions()
{
}
private DefaultJavaCoercions() {}

@FromThrift
public static Boolean booleanToBoxedBoolean(boolean value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@
@Documented
@Retention(RUNTIME)
@Target(METHOD)
public @interface FromThrift
{
}
public @interface FromThrift {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,4 @@
@Documented
@Retention(RUNTIME)
@Target(METHOD)
public @interface ToThrift
{
}
public @interface ToThrift {}
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ static void validateCreatedInstance(Class<?> clazz, Object instance)
{
verify(instance != null, "Builder method returned a null instance");

verify(
clazz.isInstance(instance),
verify(clazz.isInstance(instance),
"Builder method returned instance of type %s, but an instance of %s is required",
instance.getClass().getName(),
clazz.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
public enum FieldKind
{
THRIFT_FIELD,
THRIFT_UNION_ID
THRIFT_UNION_ID,
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,10 @@ private static final class NullMonitor
implements MetadataErrors.Monitor
{
@Override
public void onError(MetadataErrorException unused)
{
}
public void onError(MetadataErrorException unused) {}

@Override
public void onWarning(MetadataWarningException unused)
{
}
public void onWarning(MetadataWarningException unused) {}
}

public MetadataErrors()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@

public final class ReflectionHelper
{
private ReflectionHelper()
{
}
private ReflectionHelper() {}

private static final Type MAP_KEY_TYPE;
private static final Type MAP_VALUE_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ public class ThriftConstructorInjection

public ThriftConstructorInjection(Constructor<?> constructor, ThriftParameterInjection... parameters)
{
this(
requireNonNull(constructor, "constructor is null"),
this(requireNonNull(constructor, "constructor is null"),
ImmutableList.copyOf(requireNonNull(parameters, "parameters is null")));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public class ThriftFieldExtractor
private final Class<?> type;

public ThriftFieldExtractor(
short fieldId, String fieldName, FieldKind fieldKind, Field field, Type fieldType)
short fieldId,
String fieldName,
FieldKind fieldKind,
Field field,
Type fieldType)
{
this.name = requireNonNull(fieldName, "name is null");
this.field = requireNonNull(field, "field is null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ public class ThriftMethodExtractor
private final Class<?> type;

public ThriftMethodExtractor(
short fieldId, String fieldName, FieldKind fieldKind, Method method, Type fieldType)
short fieldId,
String fieldName,
FieldKind fieldKind,
Method method,
Type fieldType)
{
this.name = requireNonNull(fieldName, "name is null");
this.method = requireNonNull(method, "method is null");
Expand Down
Loading
Loading