Skip to content

Commit

Permalink
Fix for a failing Kafka operator job
Browse files Browse the repository at this point in the history
  • Loading branch information
fedinskiy committed Oct 17, 2022
1 parent 9a42e79 commit 08ef9cf
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public class BaseService<T extends Service> implements Service {
private final Map<String, String> properties = new HashMap<>();
private final List<Runnable> futureProperties = new LinkedList<>();

//TODO workaround for https://github.com/fabric8io/kubernetes-client/issues/4491
private volatile boolean isStopped = false;

private ManagedResourceBuilder managedResourceBuilder;
private ManagedResource managedResource;
private String serviceName;
Expand Down Expand Up @@ -117,7 +120,10 @@ public T withProperty(String key, Supplier<String> value) {
}

@Override
public boolean isRunning() {
public synchronized boolean isRunning() {
if (isStopped) {
return false;
}
Log.debug(this, "Checking if resource is running");
if (managedResource == null) {
Log.debug(this, "Resource is not running");
Expand Down Expand Up @@ -205,7 +211,7 @@ public void start() {
* Stop the Quarkus application.
*/
@Override
public void stop() {
public synchronized void stop() {
if (!isRunning()) {
return;
}
Expand All @@ -215,6 +221,7 @@ public void stop() {
managedResource.stop();

Log.info(this, "Service stopped (%s)", getDisplayName());
isStopped = true;
}

/**
Expand Down

0 comments on commit 08ef9cf

Please sign in to comment.