Skip to content

Commit

Permalink
[FLINK-30375][Table SQL / Client] sql-client leaks flink-table-planne…
Browse files Browse the repository at this point in the history
…r jar in /tmp (apache#21512)
  • Loading branch information
Samrat002 authored Jan 11, 2023
1 parent 176f8d5 commit 086f13a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ private PlannerModule() {
}

IOUtils.copyBytes(resourceStream, Files.newOutputStream(tempFile));
tempFile.toFile().deleteOnExit();

this.submoduleClassLoader =
new ComponentClassLoader(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,21 @@

package org.apache.flink.table.planner.loader;

import org.apache.flink.configuration.Configuration;
import org.apache.flink.configuration.ConfigurationUtils;
import org.apache.flink.table.delegation.ExecutorFactory;
import org.apache.flink.table.delegation.PlannerFactory;
import org.apache.flink.table.factories.FactoryUtil;
import org.apache.flink.util.FileUtils;
import org.apache.flink.util.TestLogger;

import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.apache.flink.table.planner.loader.PlannerModule.FLINK_TABLE_PLANNER_FAT_JAR;
import static org.assertj.core.api.Assertions.assertThat;

Expand Down Expand Up @@ -75,4 +83,13 @@ public void testPlannerFactory() {
assertThat(plannerFactory).isNotNull().isInstanceOf(DelegatePlannerFactory.class);
assertThat(plannerFactory.factoryIdentifier()).isEqualTo(PlannerFactory.DEFAULT_IDENTIFIER);
}

@Test
public void testPlannerJarLeak() throws IOException {
PlannerModule plannerModule = PlannerModule.getInstance();
final Path tmpDirectory =
Paths.get(ConfigurationUtils.parseTempDirectories(new Configuration())[0]);
Files.createDirectories(FileUtils.getTargetPathIfContainsSymbolicPath(tmpDirectory));
assertThat(tmpDirectory.startsWith("flink-table-planner_")).isEqualTo(false);
}
}

0 comments on commit 086f13a

Please sign in to comment.