Skip to content

Commit 7950d8e

Browse files
committed
Fix DevelopmentServer plugin.dir configuration
1 parent cad440a commit 7950d8e

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

lib/trino-plugin-toolkit/src/main/java/io/trino/plugin/base/ClosingBinder.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public <T> void registerResource(Key<T> key, Consumer<? super T> close)
8585
closeables.addBinding().toProvider(new ResourceCloser<T>(key, close));
8686
}
8787

88+
public void registerCloseable(AutoCloseable instance)
89+
{
90+
closeables.addBinding().toInstance(instance);
91+
}
92+
8893
private static class ResourceCloser<T>
8994
implements Provider<AutoCloseable>
9095
{

testing/trino-server-dev/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
<artifactId>trino-main</artifactId>
4141
</dependency>
4242

43+
<dependency>
44+
<groupId>io.trino</groupId>
45+
<artifactId>trino-plugin-toolkit</artifactId>
46+
</dependency>
47+
4348
<dependency>
4449
<groupId>io.trino</groupId>
4550
<artifactId>trino-spi</artifactId>

testing/trino-server-dev/src/main/java/io/trino/server/DevelopmentServer.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818
import com.google.inject.Scopes;
1919
import io.trino.server.PluginManager.PluginsProvider;
2020

21+
import java.io.IOException;
22+
import java.io.UncheckedIOException;
23+
import java.nio.file.Files;
24+
import java.nio.file.Path;
25+
2126
import static com.google.inject.multibindings.OptionalBinder.newOptionalBinder;
2227
import static io.airlift.configuration.ConfigBinder.configBinder;
28+
import static io.trino.plugin.base.ClosingBinder.closingBinder;
2329

2430
public final class DevelopmentServer
2531
extends Server
@@ -29,11 +35,24 @@ private DevelopmentServer() {}
2935
@Override
3036
protected Iterable<? extends Module> getAdditionalModules()
3137
{
32-
return ImmutableList.of(binder -> {
33-
newOptionalBinder(binder, PluginsProvider.class).setBinding()
34-
.to(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
35-
configBinder(binder).bindConfig(DevelopmentLoaderConfig.class);
36-
});
38+
try {
39+
Path pluginPath = Files.createTempDirectory("plugins");
40+
41+
return ImmutableList.of(binder -> {
42+
newOptionalBinder(binder, PluginsProvider.class).setBinding()
43+
.to(DevelopmentPluginsProvider.class).in(Scopes.SINGLETON);
44+
configBinder(binder).bindConfig(DevelopmentLoaderConfig.class);
45+
46+
// Use a temporary directory to satisfy configuration validation
47+
configBinder(binder).bindConfigDefaults(ServerPluginsProviderConfig.class, config ->
48+
config.setInstalledPluginsDirs(ImmutableList.of(pluginPath.toFile())));
49+
50+
closingBinder(binder).registerCloseable(() -> Files.deleteIfExists(pluginPath));
51+
});
52+
}
53+
catch (IOException e) {
54+
throw new UncheckedIOException(e);
55+
}
3756
}
3857

3958
public static void main(String[] args)

0 commit comments

Comments
 (0)