Skip to content

Commit

Permalink
Prevent concurrent JobServer shutdown issue
Browse files Browse the repository at this point in the history
  • Loading branch information
mxm committed Dec 18, 2018
1 parent 12bf1d3 commit 1736b9c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class FlinkJobServerDriver implements Runnable {
@VisibleForTesting ServerConfiguration configuration;
private final ServerFactory jobServerFactory;
private final ServerFactory artifactServerFactory;
private GrpcFnServer<InMemoryJobService> jobServer;
private GrpcFnServer<BeamFileSystemArtifactStagingService> artifactStagingServer;
private volatile GrpcFnServer<InMemoryJobService> jobServer;
private volatile GrpcFnServer<BeamFileSystemArtifactStagingService> artifactStagingServer;

/** Configuration for the jobServer. */
public static class ServerConfiguration {
Expand Down Expand Up @@ -184,12 +184,16 @@ public void run() {
}
}

// This method is executed by TestPortableRunner via Reflection
public String start() throws IOException {
jobServer = createJobServer();
return jobServer.getApiServiceDescriptor().getUrl();
}

public void stop() {
// This method is executed by TestPortableRunner via Reflection
// Needs to be synchronized to prevent concurrency issues in testing shutdown
@SuppressWarnings("WeakerAccess")
public synchronized void stop() {
if (jobServer != null) {
try {
jobServer.close();
Expand Down

0 comments on commit 1736b9c

Please sign in to comment.