tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From violet...@apache.org
Subject svn commit: r1722656 - in /tomcat/tc7.0.x/trunk/java/org/apache/catalina/core: StandardServer.java StandardService.java
Date Sat, 02 Jan 2016 19:55:17 GMT
Author: violetagg
Date: Sat Jan  2 19:55:16 2016
New Revision: 1722656

URL: http://svn.apache.org/viewvc?rev=1722656&view=rev
Log:
Use monitor object for synchronization

Modified:
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardService.java

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java?rev=1722656&r1=1722655&r2=1722656&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardServer.java Sat Jan  2 19:55:16
2016
@@ -134,6 +134,7 @@ public final class StandardServer extend
      * The set of Services associated with this Server.
      */
     private Service services[] = new Service[0];
+    private final Object servicesLock = new Object();
 
 
     /**
@@ -350,7 +351,7 @@ public final class StandardServer extend
 
         service.setServer(this);
 
-        synchronized (services) {
+        synchronized (servicesLock) {
             Service results[] = new Service[services.length + 1];
             System.arraycopy(services, 0, results, 0, services.length);
             results[services.length] = service;
@@ -539,7 +540,7 @@ public final class StandardServer extend
         if (name == null) {
             return (null);
         }
-        synchronized (services) {
+        synchronized (servicesLock) {
             for (int i = 0; i < services.length; i++) {
                 if (name.equals(services[i].getName())) {
                     return (services[i]);
@@ -582,7 +583,7 @@ public final class StandardServer extend
     @Override
     public void removeService(Service service) {
 
-        synchronized (services) {
+        synchronized (servicesLock) {
             int j = -1;
             for (int i = 0; i < services.length; i++) {
                 if (service == services[i]) {
@@ -732,7 +733,7 @@ public final class StandardServer extend
         globalNamingResources.start();
         
         // Start our defined Services
-        synchronized (services) {
+        synchronized (servicesLock) {
             for (int i = 0; i < services.length; i++) {
                 services[i].start();
             }

Modified: tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardService.java
URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardService.java?rev=1722656&r1=1722655&r2=1722656&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardService.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/core/StandardService.java Sat Jan  2 19:55:16
2016
@@ -90,6 +90,7 @@ public class StandardService extends Lif
      * The set of Connectors associated with this Service.
      */
     protected Connector connectors[] = new Connector[0];
+    private final Object connectorsLock = new Object();
     
     /**
      * 
@@ -229,7 +230,7 @@ public class StandardService extends Lif
     @Override
     public void addConnector(Connector connector) {
 
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             connector.setService(this);
             Connector results[] = new Connector[connectors.length + 1];
             System.arraycopy(connectors, 0, results, 0, connectors.length);
@@ -294,7 +295,7 @@ public class StandardService extends Lif
     @Override
     public void removeConnector(Connector connector) {
 
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             int j = -1;
             for (int i = 0; i < connectors.length; i++) {
                 if (connector == connectors[i]) {
@@ -451,7 +452,7 @@ public class StandardService extends Lif
         }
 
         // Start our defined Connectors second
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             for (Connector connector: connectors) {
                 try {
                     // If it has already failed, don't try and start it
@@ -480,7 +481,7 @@ public class StandardService extends Lif
     protected void stopInternal() throws LifecycleException {
 
         // Pause connectors first
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             for (Connector connector: connectors) {
                 try {
                     connector.pause();
@@ -504,7 +505,7 @@ public class StandardService extends Lif
         }
 
         // Now stop the connectors
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             for (Connector connector: connectors) {
                 if (!LifecycleState.STARTED.equals(
                         connector.getState())) {
@@ -553,7 +554,7 @@ public class StandardService extends Lif
         }
 
         // Initialize our defined Connectors
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             for (Connector connector : connectors) {
                 try {
                     connector.init();
@@ -572,7 +573,7 @@ public class StandardService extends Lif
     @Override
     protected void destroyInternal() throws LifecycleException {
         // Destroy our defined Connectors
-        synchronized (connectors) {
+        synchronized (connectorsLock) {
             for (Connector connector : connectors) {
                 try {
                     connector.destroy();



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message