initialize updateValve only once

pull/2179/head
Zhelyazko Chobantonov 6 years ago
parent 772e2b9dab
commit 77055134c2

@ -76,7 +76,7 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
private static UpdateValve updateValve;
private static Set<String> contextWithInstalledValves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private static Set<String> contextInUse = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private MessageListener messageListener;
@ -276,15 +276,16 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
throw new LifecycleException(e);
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.add(((Context) getContainer()).getName());
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.add(((Context) getContainer()).getName());
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (updateValve == null) {
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
}
if (readMode == ReadMode.MEMORY || broadcastSessionEvents) {
RTopic updatesTopic = getTopic();
@ -377,16 +378,16 @@ public class RedissonSessionManager extends ManagerBase implements Lifecycle {
@Override
public void stop() throws LifecycleException {
if (updateValve != null) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.remove(((Context) getContainer()).getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextWithInstalledValves.size() == 0) {
pipeline.removeValve(updateValve);
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.remove(((Context) getContainer()).getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextInUse.size() == 0) {
if (updateValve != null) {
pipeline.removeValve(updateValve);
updateValve = null;
}
}
}
}
}
if (messageListener != null) {

@ -73,7 +73,7 @@ public class RedissonSessionManager extends ManagerBase {
private static UpdateValve updateValve;
private static Set<String> contextWithInstalledValves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private static Set<String> contextInUse = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private MessageListener messageListener;
@ -256,15 +256,16 @@ public class RedissonSessionManager extends ManagerBase {
throw new LifecycleException(e);
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.add(((Context) getContainer()).getName());
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.add(((Context) getContainer()).getName());
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (updateValve == null) {
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
}
if (readMode == ReadMode.MEMORY || broadcastSessionEvents) {
RTopic updatesTopic = getTopic();
@ -362,16 +363,16 @@ public class RedissonSessionManager extends ManagerBase {
setState(LifecycleState.STOPPING);
if (updateValve != null) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.remove(((Context) getContainer()).getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextWithInstalledValves.size() == 0) {
pipeline.removeValve(updateValve);
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.remove(((Context) getContainer()).getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextInUse.size() == 0) {
if (updateValve != null) {
pipeline.removeValve(updateValve);
updateValve = null;
}
}
}
}
}
if (messageListener != null) {

@ -72,7 +72,7 @@ public class RedissonSessionManager extends ManagerBase {
private static UpdateValve updateValve;
private static Set<String> contextWithInstalledValves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private static Set<String> contextInUse = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private MessageListener messageListener;
@ -254,15 +254,16 @@ public class RedissonSessionManager extends ManagerBase {
throw new LifecycleException(e);
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.add(getContext().getName());
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.add(getContext().getName());
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (updateValve == null) {
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
}
if (readMode == ReadMode.MEMORY || broadcastSessionEvents) {
RTopic updatesTopic = getTopic();
@ -360,16 +361,16 @@ public class RedissonSessionManager extends ManagerBase {
setState(LifecycleState.STOPPING);
if (updateValve != null) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.remove(getContext().getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextWithInstalledValves.size() == 0) {
pipeline.removeValve(updateValve);
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.remove(getContext().getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextInUse.size() == 0) {
if (updateValve != null) {
pipeline.removeValve(updateValve);
updateValve = null;
}
}
}
}
}
if (messageListener != null) {

@ -72,7 +72,7 @@ public class RedissonSessionManager extends ManagerBase {
private static UpdateValve updateValve;
private static Set<String> contextWithInstalledValves = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private static Set<String> contextInUse = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>());
private MessageListener messageListener;
@ -254,15 +254,16 @@ public class RedissonSessionManager extends ManagerBase {
throw new LifecycleException(e);
}
if (updateMode == UpdateMode.AFTER_REQUEST) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.add(getContext().getName());
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.add(getContext().getName());
if (updateMode == UpdateMode.AFTER_REQUEST) {
if (updateValve == null) {
updateValve = new UpdateValve();
pipeline.addValve(updateValve);
}
}
}
if (readMode == ReadMode.MEMORY || broadcastSessionEvents) {
RTopic updatesTopic = getTopic();
@ -360,16 +361,16 @@ public class RedissonSessionManager extends ManagerBase {
setState(LifecycleState.STOPPING);
if (updateValve != null) {
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextWithInstalledValves.remove(getContext().getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextWithInstalledValves.size() == 0) {
pipeline.removeValve(updateValve);
Pipeline pipeline = getEngine().getPipeline();
synchronized (pipeline) {
contextInUse.remove(getContext().getName());
//remove valves when all of the RedissonSessionManagers (web apps) are not in use anymore
if (contextInUse.size() == 0) {
if (updateValve != null) {
pipeline.removeValve(updateValve);
updateValve = null;
}
}
}
}
}
if (messageListener != null) {

Loading…
Cancel
Save