Skip to content

Commit

Permalink
fix AbstractLifeCycle concurrency problem Fixes gh-163 (#188)
Browse files Browse the repository at this point in the history
* fix AbstractLifeCycle concurrency problem Fixes gh-163

* fix AbstractLifeCycle concurrency problem Fixes gh-163

* fix  AsynMultiInterestUserProcessor dispatch to sync handleRequest  method problem. gh-157

* Revert "fix  AsynMultiInterestUserProcessor dispatch to sync handleRequest  method problem. gh-157"

This reverts commit 2784f9e.
  • Loading branch information
lollapalooza1989 authored and cytnju committed Nov 29, 2019
1 parent 4e99a8e commit 391317d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main/java/com/alipay/remoting/AbstractLifeCycle.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,34 @@
*/
package com.alipay.remoting;

import java.util.concurrent.atomic.AtomicBoolean;

/**
* @author chengyi ([email protected]) 2018-11-05 14:43
*/
public abstract class AbstractLifeCycle implements LifeCycle {

private volatile boolean isStarted = false;
private final AtomicBoolean isStarted = new AtomicBoolean(false);

@Override
public void startup() throws LifeCycleException {
if (!isStarted) {
isStarted = true;
if (isStarted.compareAndSet(false, true)) {
return;
}

throw new LifeCycleException("this component has started");
}

@Override
public void shutdown() throws LifeCycleException {
if (isStarted) {
isStarted = false;
if (isStarted.compareAndSet(true, false)) {
return;
}

throw new LifeCycleException("this component has closed");
}

@Override
public boolean isStarted() {
return isStarted;
return isStarted.get();
}

}

0 comments on commit 391317d

Please sign in to comment.