Skip to content

Commit

Permalink
Remove redundant return value from closingBinder registration
Browse files Browse the repository at this point in the history
Align closingBinder API with helpers such as configBinder or
jaxrsBinder. This also clears an IDE warning about unused return value.
  • Loading branch information
findepi committed Apr 10, 2024
1 parent 1c8eadf commit 0ace3a7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,10 @@ List<OutputStatsEstimatorFactory> getCompositeOutputDataSizeEstimatorDelegateFac
install(new QueryExecutionFactoryModule());

// cleanup
closingBinder(binder)
.registerExecutor(Key.get(ExecutorService.class, ForStatementResource.class))
.registerExecutor(Key.get(ScheduledExecutorService.class, ForStatementResource.class))
.registerExecutor(Key.get(ExecutorService.class, ForQueryExecution.class))
.registerExecutor(Key.get(ScheduledExecutorService.class, ForScheduler.class));
closingBinder(binder).registerExecutor(Key.get(ExecutorService.class, ForStatementResource.class));
closingBinder(binder).registerExecutor(Key.get(ScheduledExecutorService.class, ForStatementResource.class));
closingBinder(binder).registerExecutor(Key.get(ExecutorService.class, ForQueryExecution.class));
closingBinder(binder).registerExecutor(Key.get(ScheduledExecutorService.class, ForScheduler.class));
}

// working around circular dependency Metadata <-> PlannerContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -496,10 +496,9 @@ protected void setup(Binder binder)
newOptionalBinder(binder, RuleStatsRecorder.class);

// cleanup
closingBinder(binder)
.registerExecutor(Key.get(ScheduledExecutorService.class, ForExchange.class))
.registerExecutor(Key.get(ExecutorService.class, ForAsyncHttp.class))
.registerExecutor(Key.get(ScheduledExecutorService.class, ForAsyncHttp.class));
closingBinder(binder).registerExecutor(Key.get(ScheduledExecutorService.class, ForExchange.class));
closingBinder(binder).registerExecutor(Key.get(ExecutorService.class, ForAsyncHttp.class));
closingBinder(binder).registerExecutor(Key.get(ScheduledExecutorService.class, ForAsyncHttp.class));
}

private static class RegisterFunctionBundles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ public class InMemoryTransactionManagerModule
public void configure(Binder binder)
{
configBinder(binder).bindConfig(TransactionManagerConfig.class);
closingBinder(binder)
.registerExecutor(Key.get(ExecutorService.class, ForTransactionManager.class))
.registerExecutor(Key.get(ScheduledExecutorService.class, ForTransactionManager.class));
closingBinder(binder).registerExecutor(Key.get(ExecutorService.class, ForTransactionManager.class));
closingBinder(binder).registerExecutor(Key.get(ScheduledExecutorService.class, ForTransactionManager.class));
}

@Provides
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,24 @@ private ClosingBinder(Binder binder)
binder.bind(Cleanup.class).asEagerSingleton();
}

public ClosingBinder registerExecutor(Class<? extends ExecutorService> type)
public void registerExecutor(Class<? extends ExecutorService> type)
{
return registerExecutor(Key.get(type));
registerExecutor(Key.get(type));
}

public ClosingBinder registerExecutor(Key<? extends ExecutorService> key)
public void registerExecutor(Key<? extends ExecutorService> key)
{
executors.addBinding().to(requireNonNull(key, "key is null"));
return this;
}

public ClosingBinder registerCloseable(Class<? extends Closeable> type)
public void registerCloseable(Class<? extends Closeable> type)
{
return registerCloseable(Key.get(type));
registerCloseable(Key.get(type));
}

public ClosingBinder registerCloseable(Key<? extends Closeable> key)
public void registerCloseable(Key<? extends Closeable> key)
{
closeables.addBinding().to(key);
return this;
}

private record Cleanup(
Expand Down

0 comments on commit 0ace3a7

Please sign in to comment.