[tomcat] branch master updated: Refine fix for apparent end of stream concurrency with async

2019-05-23 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 317480b  Refine fix for apparent end of stream concurrency with async
317480b is described below

commit 317480b90546a69bdf661e747cb89dda8727d462
Author: remm 
AuthorDate: Fri May 24 00:33:42 2019 +0200

Refine fix for apparent end of stream concurrency with async

Needs testing.
---
 java/org/apache/coyote/http2/Http2AsyncParser.java | 7 +++
 webapps/docs/changelog.xml | 3 +++
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java 
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index 84342a4..ba3ec3a 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -240,14 +240,14 @@ class Http2AsyncParser extends Http2Parser {
 if (streamException) {
 swallow(streamId, payloadSize, false, payload);
 } else {
-// TODO: Find why this sync is needed
-synchronized (input) {
 switch (frameType) {
 case DATA:
 readDataFrame(streamId, flags, payloadSize, 
payload);
 break;
 case HEADERS:
-readHeadersFrame(streamId, flags, payloadSize, 
payload);
+synchronized (upgradeHandler) {
+readHeadersFrame(streamId, flags, 
payloadSize, payload);
+}
 break;
 case PRIORITY:
 readPriorityFrame(streamId, payload);
@@ -276,7 +276,6 @@ class Http2AsyncParser extends Http2Parser {
 case UNKNOWN:
 readUnknownFrame(streamId, frameType, flags, 
payloadSize, payload);
 }
-}
 }
 // See if there is a new 9 byte header and continue 
parsing if possible
 if (payload.remaining() >= 9) {
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 3155c8c..a6979de 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -152,6 +152,9 @@
 Drop legacy NIO double socket close (close channel, then close
 socket). (remm)
   
+  
+Fix HTTP/2 end of stream concurrency with async. (remm)
+  
 
   
   


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



[tomcat] branch 7.0.x updated: Update the location of the Java EE schemas

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
 new 86ab275  Update the location of the Java EE schemas
86ab275 is described below

commit 86ab2750f7082390b182cb95e3b6550e1b697fc5
Author: Mark Thomas 
AuthorDate: Thu May 23 23:21:22 2019 +0100

Update the location of the Java EE schemas
---
 NOTICE | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/NOTICE b/NOTICE
index 4156a63..764c897 100644
--- a/NOTICE
+++ b/NOTICE
@@ -33,4 +33,6 @@ The original XML Schemas for Java EE Deployment Descriptors:
  - web-app_3_0.xsd
  - web-common_3_0.xsd
  - web-fragment_3_0.xsd
-may be obtained from http://java.sun.com/xml/ns/javaee/
+
+may be obtained from:
+http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html


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



[tomcat] branch 8.5.x updated: Tomcat 8.5.x does not include the Java EE 8 schemas

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
 new 14f3bf5  Tomcat 8.5.x does not include the Java EE 8 schemas
14f3bf5 is described below

commit 14f3bf543e870ddef11b56213f9fffec4f71208b
Author: Mark Thomas 
AuthorDate: Thu May 23 23:21:01 2019 +0100

Tomcat 8.5.x does not include the Java EE 8 schemas

This was missed when Tomcat 8.5.x was created from Tomcat 9.
---
 LICENSE| 4 
 res/INSTALLLICENSE | 4 
 2 files changed, 8 deletions(-)

diff --git a/LICENSE b/LICENSE
index e6a6baf..112c0b4 100644
--- a/LICENSE
+++ b/LICENSE
@@ -725,10 +725,6 @@ For the following XML Schemas for Java EE Deployment 
Descriptors:
  - web-app_3_1.xsd
  - web-common_3_1.xsd
  - web-fragment_3_1.xsd
- - javaee_8.xsd
- - web-app_4_0.xsd
- - web-common_4_0.xsd
- - web-fragment_4_0.xsd
 
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
 
diff --git a/res/INSTALLLICENSE b/res/INSTALLLICENSE
index e6a6baf..112c0b4 100644
--- a/res/INSTALLLICENSE
+++ b/res/INSTALLLICENSE
@@ -725,10 +725,6 @@ For the following XML Schemas for Java EE Deployment 
Descriptors:
  - web-app_3_1.xsd
  - web-common_3_1.xsd
  - web-fragment_3_1.xsd
- - javaee_8.xsd
- - web-app_4_0.xsd
- - web-common_4_0.xsd
- - web-fragment_4_0.xsd
 
 COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0
 


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



[tomcat] branch 7.0.x updated: Add the necessary plumbing to allow the Windows installer to be signed.

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
 new b40ee49  Add the necessary plumbing to allow the Windows installer to 
be signed.
b40ee49 is described below

commit b40ee494b192d6d1d8b930b3269e0954d50e7537
Author: Mark Thomas 
AuthorDate: Thu May 23 23:10:49 2019 +0100

Add the necessary plumbing to allow the Windows installer to be signed.

The motivation for this was aligning the tomcat.nsi files across the
currently supported versions in preparation for implementing BZ 55969.
The changes to the installer required changes in the build script so it
seemed reasonable to provide all of the plumbing necessary for signing.
---
 build.xml| 106 +-
 java/org/apache/tomcat/buildutil/SignCode.java   | 435 +++
 java/org/apache/tomcat/util/buf/StringUtils.java | 105 ++
 res/checkstyle/org-import-control.xml|   1 +
 res/tomcat.nsi   | 286 ---
 5 files changed, 792 insertions(+), 141 deletions(-)

diff --git a/build.xml b/build.xml
index 92d8b92..2b1ed37 100644
--- a/build.xml
+++ b/build.xml
@@ -498,7 +498,7 @@
   
 
   
-  
+
   
 
 
@@ -2168,9 +2168,26 @@ Apache Tomcat ${version} native binaries for Win64 
AMD64/EMT64 platform.
 
   
 
-  
-
+  
+
+
+  
+
+
+
+  
+
+  
+
+  
+
+  
+
+  
 
   
 
@@ -2187,31 +2204,102 @@ Apache Tomcat ${version} native binaries for Win64 
AMD64/EMT64 platform.
 
   
 
-
 
   
 
+  
 
+  
 
+  
   
   
   
 
 
   
+  
   
   
   
 
+  
+
+  
+
+
+
+  
+
+
+  
 
+  
+
+
+  
+
+  
+
+  
+
+  
+
+  
+  
+  
+
+
+  
+  
+  
+  
+
 
 
   
 
+  
+
+
+  
+
+  
+
+
+
+
+
+  
+
   
+
depends="clean,release-init,dist-deployer,installer-sign,package-zip,package-winzip,package-tgz,package-deployer-zip,package-deployer-tgz,javadoc,package-docs-tgz,package-src-zip,package-src-tgz,package-src-jar"
+description="Create a Tomcat packaged distribution">
 
 
@@ -2680,6 +2768,7 @@ Apache Tomcat ${version} native binaries for Win64 
AMD64/EMT64 platform.
   
   
 
+
   
 
   
 
-
   
 
   
@@ -3055,6 +3143,8 @@ Apache Tomcat ${version} native binaries for Win64 
AMD64/EMT64 platform.
 
   
 
+  
+
   
diff --git a/java/org/apache/tomcat/buildutil/SignCode.java 
b/java/org/apache/tomcat/buildutil/SignCode.java
new file mode 100644
index 000..20b6bed
--- /dev/null
+++ b/java/org/apache/tomcat/buildutil/SignCode.java
@@ -0,0 +1,435 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  See the NOTICE file distributed with
+* this work for additional information regarding copyright ownership.
+* The ASF licenses this file to You under the Apache License, Version 2.0
+* (the "License"); you may not use this file except in compliance with
+* the License.  You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package org.apache.tomcat.buildutil;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import java.util.zip.ZipOutputStream;
+
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPBody;
+import javax.xml.soap.SOAPConnection;
+import javax.xml.soap.SOAPConnectionFactory;
+import javax.xml.soap.SOAPConstants;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPEnvelope;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+import javax.xml.soap.SOAPPart;
+
+import org.apache.tomcat.util.buf.StringUtils;
+import org.apache.tomcat.util.codec.binary.Base64;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.types.FileSet;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+/**
+ * Ant task that submits a file to the Symantec code-signing service.
+ 

[tomcat] branch 7.0.x updated: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=43548

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
 new 3104c3d  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=43548
3104c3d is described below

commit 3104c3d2b7b4c8191734241140992babe9f7e920
Author: Mark Thomas 
AuthorDate: Thu May 23 22:07:49 2019 +0100

Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=43548

Add an XML schema for the tomcat-users.xml file.
---
 conf/tomcat-users.xml  |  7 +++--
 conf/tomcat-users.xsd  | 59 ++
 res/confinstall/tomcat-users_1.xml |  5 +++-
 webapps/docs/changelog.xml |  4 +++
 4 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/conf/tomcat-users.xml b/conf/tomcat-users.xml
index 1df2648..aef66d0 100644
--- a/conf/tomcat-users.xml
+++ b/conf/tomcat-users.xml
@@ -1,4 +1,4 @@
-
+
 
-
+http://tomcat.apache.org/xml;
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
+  xsi:schemaLocation="http://tomcat.apache.org/xml 
tomcat-users.xsd"
+  version="1.0">
 
+http://www.w3.org/2001/XMLSchema;
+   targetNamespace="http://tomcat.apache.org/xml;
+   xmlns:users="http://tomcat.apache.org/xml;
+   xmlns:xs="http://www.w3.org/2001/XMLSchema;
+   elementFormDefault="qualified"
+   attributeFormDefault="unqualified"
+   version="1.0">
+  
+
+  
+
+  
+
+
+  
+
+
+  
+
+
+
+  
+
+
+  
+
+
+
+
+
+  
+
+  
+  
+
+  
+  
+
+  
+
+  
+
\ No newline at end of file
diff --git a/res/confinstall/tomcat-users_1.xml 
b/res/confinstall/tomcat-users_1.xml
index cde187d..6c2b669 100644
--- a/res/confinstall/tomcat-users_1.xml
+++ b/res/confinstall/tomcat-users_1.xml
@@ -14,4 +14,7 @@
   See the License for the specific language governing permissions and
   limitations under the License.
 -->
-
+http://tomcat.apache.org/xml;
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance;
+  xsi:schemaLocation="http://tomcat.apache.org/xml 
tomcat-users.xsd"
+  version="1.0">
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 07e9038..5791513 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -94,6 +94,10 @@
 defined in server.xml with a docBase but not
 the optional path. (markt)
   
+  
+43548: Add an XML schema for the tomcat-users.xml file.
+(markt)
+  
   
 63324: Refactor the CrawlerSessionManagerValve
 so that the object placed in the session is compatible with session


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



[Bug 43548] xml schema for tomcat-users.xml

2019-05-23 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=43548

--- Comment #11 from Mark Thomas  ---
Five years on and I changed my mind. I've added this to 7.0.x for 7.0.95
onwards.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 55969] Security-related enhancements to the Windows Installer

2019-05-23 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=55969

--- Comment #1 from Mark Thomas  ---
Just a note to say that I am working on this. I have updated Commons Daemon to
offer LocalService and NetworkService in the UI. Note it will need a Commons
Daemon release to make this available to Tomcat and there are still some open
issues to fix in Daemon.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[tomcat] branch master updated: Sync to avoid apparent HTTP/2 state problems

2019-05-23 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new 49ff470  Sync to avoid apparent HTTP/2 state problems
49ff470 is described below

commit 49ff4703e46feb23ec1dd3a9f3576231446f6dee
Author: remm 
AuthorDate: Thu May 23 22:10:55 2019 +0200

Sync to avoid apparent HTTP/2 state problems

Using the HTTP/2 demo page (the one with 100s of tomcat.gif that was
used at ApacheCons in the past), I could see some errors caused by the
state check line 1530 in Http2UpgradeHandler, the state being CLOSED_RX
(so no window updating).
---
 java/org/apache/coyote/http2/Http2AsyncParser.java | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/java/org/apache/coyote/http2/Http2AsyncParser.java 
b/java/org/apache/coyote/http2/Http2AsyncParser.java
index 827105a..84342a4 100644
--- a/java/org/apache/coyote/http2/Http2AsyncParser.java
+++ b/java/org/apache/coyote/http2/Http2AsyncParser.java
@@ -240,6 +240,8 @@ class Http2AsyncParser extends Http2Parser {
 if (streamException) {
 swallow(streamId, payloadSize, false, payload);
 } else {
+// TODO: Find why this sync is needed
+synchronized (input) {
 switch (frameType) {
 case DATA:
 readDataFrame(streamId, flags, payloadSize, 
payload);
@@ -274,6 +276,7 @@ class Http2AsyncParser extends Http2Parser {
 case UNKNOWN:
 readUnknownFrame(streamId, frameType, flags, 
payloadSize, payload);
 }
+}
 }
 // See if there is a new 9 byte header and continue 
parsing if possible
 if (payload.remaining() >= 9) {


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



Re: Proposal for TLS config sanity check

2019-05-23 Thread Coty Sutherland
On Tue, May 21, 2019 at 5:43 PM Mark Thomas  wrote:

> On 21/05/2019 21:46, Christopher Schultz wrote:
> > All,
> >
> > Looking at the legacy-versus-modern TLS configuration (Connector vs
> > SSLHostConfig), it seems easy for an admin to create a configuration
> > that looks like this (paraphrasing):
> >
> > 
> >>hostname="mysite.com"
> >SSLCertificateFile="keystore.p12" />
> > 
> >
> > Where the expectation is that only TLSv1.2 will be enabled for virsual
> > host mysite.com when in fact only the virtual host named ("_default_")
> > will actually be limited to TLSv1.2 and other hosts will accept
> > connections using a TLS handshake with all default enabled protocols
> > (currently TLSv*).
> >
> > This may be surprising and there is no indication that there is
> > something "wrong" with the configuration. Only a TLS handshake probe
> > such as SSL Labs's testing tool will expose the oversight.
> >
> > I propose the following change to the  and 
> > initialization process:
> >
> > If the  contains any TLS/SSL-related configuration AND at
> > least one  element is configured, refuse to start the
> > connector (with an appropriate error message).
> >
> > This may cause a small number of configurations to fail to start. The
> > "workaround" is to re-evaluate one's configuration to (a) determine if
> > there was a misconfiguration where expectation and reality don't match
> > and (b) move all TLS/SSL-related configuration options from the
> >  to each of the  elements.
> >
> > Any objections?
>

Seems like a good idea to me.


>
> None.
>
> Given that the old style configuration is due to be removed in Tomcat
> 10, now is probably a good time to start doing this. I'd add logging a
> warning if the deprecated config style is used.
>

+1


>
> Mark
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>


[tomcat] branch 7.0.x updated: Review o.a.catalina.ha.session and minimise diff

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/7.0.x by this push:
 new 110d281  Review o.a.catalina.ha.session and minimise diff
110d281 is described below

commit 110d281d4cf37da85ec5ab0eca853af5e5774e53
Author: Mark Thomas 
AuthorDate: Thu May 23 13:08:20 2019 +0100

Review o.a.catalina.ha.session and minimise diff

First pass at reducing diff between 9.0.x. 8.5.x and 7.0.x to simplify
backports. Mostly whitespace and NO-OP refactorings.
---
 .../apache/catalina/ha/session/BackupManager.java  |  17 +-
 .../catalina/ha/session/ClusterManagerBase.java|  37 ++-
 .../ha/session/ClusterSessionListener.java |   9 +-
 .../apache/catalina/ha/session/DeltaManager.java   | 314 +
 .../apache/catalina/ha/session/DeltaRequest.java   |  59 ++--
 .../apache/catalina/ha/session/DeltaSession.java   |  28 +-
 .../catalina/ha/session/JvmRouteBinderValve.java   |  73 ++---
 .../apache/catalina/ha/session/SessionMessage.java |  12 +-
 .../catalina/ha/session/SessionMessageImpl.java|  16 +-
 .../catalina/ha/session/mbeans-descriptors.xml |  18 +-
 10 files changed, 330 insertions(+), 253 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/BackupManager.java 
b/java/org/apache/catalina/ha/session/BackupManager.java
index 996564d..565a824 100644
--- a/java/org/apache/catalina/ha/session/BackupManager.java
+++ b/java/org/apache/catalina/ha/session/BackupManager.java
@@ -17,7 +17,6 @@
 package org.apache.catalina.ha.session;
 
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Set;
 
 import org.apache.catalina.DistributedManager;
@@ -45,7 +44,7 @@ public class BackupManager extends ClusterManagerBase
 /**
  * The string manager for this package.
  */
-protected static final StringManager sm = 
StringManager.getManager(Constants.Package);
+protected static final StringManager sm = 
StringManager.getManager(BackupManager.class);
 
 protected static long DEFAULT_REPL_TIMEOUT = 15000;//15 seconds
 
@@ -132,7 +131,7 @@ public class BackupManager extends ClusterManagerBase
 //=
 @Override
 public void objectMadePrimay(Object key, Object value) {
-if (value!=null && value instanceof DeltaSession) {
+if (value instanceof DeltaSession) {
 DeltaSession session = (DeltaSession)value;
 synchronized (session) {
 session.access();
@@ -172,10 +171,9 @@ public class BackupManager extends ClusterManagerBase
 
 try {
 if (cluster == null) throw new 
LifecycleException(sm.getString("backupManager.noCluster", getName()));
-LazyReplicatedMap map =
-new LazyReplicatedMap(this,
-cluster.getChannel(), rpcTimeout, getMapName(),
-getClassLoaders(), terminateOnStartFailure);
+LazyReplicatedMap map = new 
LazyReplicatedMap(
+this, cluster.getChannel(), rpcTimeout, getMapName(),
+getClassLoaders(), terminateOnStartFailure);
 map.setChannelSendOptions(mapSendOptions);
 map.setAccessTimeout(accessTimeout);
 this.sessions = map;
@@ -286,9 +284,8 @@ public class BackupManager extends ClusterManagerBase
 Set sessionIds = new HashSet();
 LazyReplicatedMap map =
 (LazyReplicatedMap)sessions;
-Iterator keys = map.keySetFull().iterator();
-while (keys.hasNext()) {
-sessionIds.add(keys.next());
+for (String id : map.keySetFull()) {
+sessionIds.add(id);
 }
 return sessionIds;
 }
diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java 
b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index 89121aa..684b6b4 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -14,11 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.catalina.ha.session;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
 
 import org.apache.catalina.Cluster;
 import org.apache.catalina.Container;
@@ -39,8 +39,7 @@ import org.apache.tomcat.util.collections.SynchronizedStack;
  *
  * @author Filip Hanik
  */
-public abstract class ClusterManagerBase extends ManagerBase
-implements ClusterManager {
+public abstract class ClusterManagerBase extends ManagerBase implements 
ClusterManager {
 
 private final Log log = LogFactory.getLog(ClusterManagerBase.class); // 
must not be static
 
@@ -147,21 +146,25 @@ 

[tomcat] branch 8.5.x updated: Review o.a.catalina.ha.session and minimise diff

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
 new c6b3a97  Review o.a.catalina.ha.session and minimise diff
c6b3a97 is described below

commit c6b3a979f99aac09712b930a73d31acfd54b0975
Author: Mark Thomas 
AuthorDate: Thu May 23 13:06:28 2019 +0100

Review o.a.catalina.ha.session and minimise diff

First pass at reducing diff between 9.0.x. 8.5.x and 7.0.x to simplify
backports. Mostly whitespace and NO-OP refactorings.
---
 .../catalina/ha/session/ClusterSessionListener.java   |  4 +---
 java/org/apache/catalina/ha/session/DeltaManager.java | 19 ---
 java/org/apache/catalina/ha/session/DeltaRequest.java |  6 ++
 java/org/apache/catalina/ha/session/DeltaSession.java | 18 ++
 4 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/ClusterSessionListener.java 
b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
index e9f5d28..8836854 100644
--- a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
+++ b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
@@ -88,10 +88,8 @@ public class ClusterSessionListener extends ClusterListener {
 cluster.send(replymsg, msg.getAddress());
 }
 }
-
 }
 }
-return;
 }
 
 /**
@@ -105,7 +103,7 @@ public class ClusterSessionListener extends ClusterListener 
{
  */
 @Override
 public boolean accept(ClusterMessage msg) {
-return (msg instanceof SessionMessage);
+return msg instanceof SessionMessage;
 }
 }
 
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index cce8840..21c6efa 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -24,7 +24,6 @@ import java.io.ObjectInputStream;
 import java.io.ObjectOutputStream;
 import java.util.ArrayList;
 import java.util.Date;
-import java.util.Iterator;
 
 import org.apache.catalina.Engine;
 import org.apache.catalina.Host;
@@ -303,7 +302,7 @@ public class DeltaManager extends ClusterManagerBase{
 
 /**
  * Set that state transferred is complete
- * @param stateTransfered Fag value
+ * @param stateTransfered Flag value
  */
 public void setStateTransfered(boolean stateTransfered) {
 this.stateTransfered = stateTransfered;
@@ -432,7 +431,7 @@ public class DeltaManager extends ClusterManagerBase{
 if (log.isDebugEnabled())
 log.debug(sm.getString("deltaManager.createSession.newSession",
 session.getId(), Integer.valueOf(sessions.size(;
-return (session);
+return session;
 }
 
 /**
@@ -479,6 +478,7 @@ public class DeltaManager extends ClusterManagerBase{
 
 /**
  * Get new session class to be used in the doLoad() method.
+ *
  * @return a new session
  *
  * @deprecated Unused. This will be removed in Tomcat 10.
@@ -775,9 +775,7 @@ public class DeltaManager extends ClusterManagerBase{
 waitForSendAllSessions(beforeSendTime);
 } finally {
 synchronized(receivedMessageQueue) {
-for (Iterator iter = 
receivedMessageQueue.iterator();
-iter.hasNext();) {
-SessionMessage smsg = iter.next();
+for (SessionMessage smsg : receivedMessageQueue) {
 if (!stateTimestampDrop) {
 messageReceived(smsg, smsg.getAddress());
 } else {
@@ -864,7 +862,7 @@ public class DeltaManager extends ClusterManagerBase{
 new Date(beforeSendTime), Long.valueOf(reqNow - 
beforeSendTime)));
 } else {
 if (log.isInfoEnabled())
-log.info(sm.getString("deltaManager.sessionReceived",getName(),
+log.info(sm.getString("deltaManager.sessionReceived", 
getName(),
 new Date(beforeSendTime), Long.valueOf(reqNow - 
beforeSendTime)));
 }
 }
@@ -1025,7 +1023,7 @@ public class DeltaManager extends ClusterManagerBase{
  sessionId + "-" + 
System.currentTimeMillis());
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("deltaManager.createMessage.access",
-getName(),sessionId));
+getName(), sessionId));
 }
 }
 }
@@ -1112,7 +1110,7 @@ public class DeltaManager extends ClusterManagerBase{
 int expireDirect  = 0 ;
 int expireIndirect = 0 ;
 
-

[tomcat] branch master updated: Review o.a.catalina.ha.session and minimise diff

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
 new d6d3b31  Review o.a.catalina.ha.session and minimise diff
d6d3b31 is described below

commit d6d3b31d7ac461933f30bc6b0a36af777657299e
Author: Mark Thomas 
AuthorDate: Thu May 23 13:04:09 2019 +0100

Review o.a.catalina.ha.session and minimise diff

First pass at reducing diff between 9.0.x. 8.5.x and 7.0.x to simplify
backports. Mostly whitespace and NO-OP refactorings.
---
 .../org/apache/catalina/ha/session/ClusterSessionListener.java |  1 -
 java/org/apache/catalina/ha/session/DeltaManager.java  | 10 +-
 java/org/apache/catalina/ha/session/DeltaSession.java  |  8 
 3 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/ClusterSessionListener.java 
b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
index c2c36b4..8836854 100644
--- a/java/org/apache/catalina/ha/session/ClusterSessionListener.java
+++ b/java/org/apache/catalina/ha/session/ClusterSessionListener.java
@@ -88,7 +88,6 @@ public class ClusterSessionListener extends ClusterListener {
 cluster.send(replymsg, msg.getAddress());
 }
 }
-
 }
 }
 }
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 3ee3fbe..54a1e5d 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -473,6 +473,7 @@ public class DeltaManager extends ClusterManagerBase{
 
 /**
  * Get new session class to be used in the doLoad() method.
+ *
  * @return a new session
  *
  * @deprecated Unused. This will be removed in Tomcat 10.
@@ -856,7 +857,7 @@ public class DeltaManager extends ClusterManagerBase{
 new Date(beforeSendTime), Long.valueOf(reqNow - 
beforeSendTime)));
 } else {
 if (log.isInfoEnabled())
-log.info(sm.getString("deltaManager.sessionReceived",getName(),
+log.info(sm.getString("deltaManager.sessionReceived", 
getName(),
 new Date(beforeSendTime), Long.valueOf(reqNow - 
beforeSendTime)));
 }
 }
@@ -1017,7 +1018,7 @@ public class DeltaManager extends ClusterManagerBase{
  sessionId + "-" + 
System.currentTimeMillis());
 if (log.isDebugEnabled()) {
 log.debug(sm.getString("deltaManager.createMessage.access",
-getName(),sessionId));
+getName(), sessionId));
 }
 }
 }
@@ -1104,7 +1105,7 @@ public class DeltaManager extends ClusterManagerBase{
 int expireDirect  = 0 ;
 int expireIndirect = 0 ;
 
-if(log.isDebugEnabled()) {
+if (log.isDebugEnabled()) {
 log.debug("Start expire all sessions " + getName() + " at " + 
timeNow +
 " sessioncount " + sessions.length);
 }
@@ -1122,13 +1123,12 @@ public class DeltaManager extends ClusterManagerBase{
 }//end if
 }//for
 long timeEnd = System.currentTimeMillis();
-if(log.isDebugEnabled()) {
+if (log.isDebugEnabled()) {
 log.debug("End expire sessions " + getName() +
 " expire processingTime " + (timeEnd - timeNow) +
 " expired direct sessions: " + expireDirect +
 " expired direct sessions: " + expireIndirect);
 }
-
 }
 
 @Override
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 4147fc0..947fa62 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -341,7 +341,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 lockInternal();
 try {
 deltaRequest.setMaxInactiveInterval(interval);
-} finally{
+} finally {
 unlockInternal();
 }
 }
@@ -364,7 +364,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 lockInternal();
 try {
 deltaRequest.setNew(isNew);
-} finally{
+} finally {
 unlockInternal();
 }
 }
@@ -531,7 +531,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 try {
 super.recycle();
 deltaRequest.clear();
-} finally{
+} finally {
 

[tomcat] 06/06: Refactor #requestCompleted to re-use DeltaSession#getDiff()

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6421a8c0f5beb06683c7a0535560a51fb8c52c62
Author: Mark Thomas 
AuthorDate: Wed May 22 12:07:35 2019 +0100

Refactor #requestCompleted to re-use DeltaSession#getDiff()
---
 .../org/apache/catalina/ha/session/DeltaManager.java | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 25b3f96..0ee5251 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -38,7 +38,6 @@ import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.tribes.Member;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -971,8 +970,6 @@ public class DeltaManager extends ClusterManagerBase{
 public ClusterMessage requestCompleted(String sessionId, boolean expires) {
 DeltaSession session = null;
 SessionMessage msg = null;
-SynchronizedStack deltaRequestPool = 
getDeltaRequestPool();
-DeltaRequest deltaRequest = null;
 try {
 session = (DeltaSession) findSession(sessionId);
 if (session == null) {
@@ -980,30 +977,17 @@ public class DeltaManager extends ClusterManagerBase{
 // removed the session from the Manager.
 return null;
 }
-DeltaRequest newDeltaRequest = deltaRequestPool.pop();
-if (newDeltaRequest == null) {
-// Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
-}
-deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
-if (deltaRequest.getSize() > 0) {
+if (session.isDirty()) {
 counterSend_EVT_SESSION_DELTA++;
-byte[] data = deltaRequest.serialize();
 msg = new SessionMessageImpl(getName(),
  SessionMessage.EVT_SESSION_DELTA,
- data,
+ session.getDiff(),
  sessionId,
  sessionId + "-" + 
System.currentTimeMillis());
 }
 } catch (IOException x) {
 
log.error(sm.getString("deltaManager.createMessage.unableCreateDeltaRequest",sessionId),
 x);
 return null;
-} finally {
-if (deltaRequest != null) {
-// Reset the instance before it is returned to the pool
-deltaRequest.reset();
-deltaRequestPool.push(deltaRequest);
-}
 }
 if(msg == null) {
 if(!expires && !session.isPrimarySession()) {


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



[tomcat] 03/06: Refactor to create internal lock methods.

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 020b84938cefec71324537d52fbe6b5b2f674617
Author: Mark Thomas 
AuthorDate: Tue May 21 22:02:40 2019 +0100

Refactor to create internal lock methods.

This is a step on the path to making ReplicatedMapEntry#lock() and
unlock() NO-OPs.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 98 --
 1 file changed, 53 insertions(+), 45 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 7efafc6..08f0cd2 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -138,11 +138,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-try{
-lock();
+lockInternal();
+try {
 return getDeltaRequest().serialize();
-}finally{
-unlock();
+} finally {
+unlockInternal();
 }
 }
 
@@ -168,9 +168,9 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public void applyDiff(byte[] diff, int offset, int length) throws 
IOException, ClassNotFoundException {
+lockInternal();
 try {
-lock();
-ReplicationStream stream = ( (ClusterManager) 
getManager()).getReplicationStream(diff, offset, length);
+ReplicationStream stream = ((ClusterManager) 
getManager()).getReplicationStream(diff, offset, length);
 ClassLoader contextLoader = 
Thread.currentThread().getContextClassLoader();
 try {
 ClassLoader[] loaders = getClassLoaders();
@@ -182,8 +182,8 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 } finally {
 Thread.currentThread().setContextClassLoader(contextLoader);
 }
-}finally {
-unlock();
+} finally {
+unlockInternal();
 }
 }
 
@@ -195,19 +195,27 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 resetDeltaRequest();
 }
 
+@Override
+public void lock() {
+lockInternal();
+}
+
+@Override
+public void unlock() {
+unlockInternal();
+}
+
 /**
  * Lock during serialization
  */
-@Override
-public void lock() {
+private void lockInternal() {
 diffLock.lock();
 }
 
 /**
  * Unlock after serialization
  */
-@Override
-public void unlock() {
+private void unlockInternal() {
 diffLock.unlock();
 }
 
@@ -302,11 +310,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setMaxInactiveInterval(int interval, boolean addDeltaRequest) {
 super.maxInactiveInterval = interval;
 if (addDeltaRequest) {
-lock();
+lockInternal();
 try {
 deltaRequest.setMaxInactiveInterval(interval);
 } finally {
-unlock();
+unlockInternal();
 }
 }
 }
@@ -325,11 +333,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setNew(boolean isNew, boolean addDeltaRequest) {
 super.setNew(isNew);
 if (addDeltaRequest){
-lock();
+lockInternal();
 try {
 deltaRequest.setNew(isNew);
-}finally{
-unlock();
+} finally {
+unlockInternal();
 }
 }
 }
@@ -349,13 +357,13 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setPrincipal(Principal principal, boolean addDeltaRequest) {
+lockInternal();
 try {
-lock();
 super.setPrincipal(principal);
 if (addDeltaRequest)
 deltaRequest.setPrincipal(principal);
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -371,14 +379,14 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setAuthType(String authType, boolean addDeltaRequest) {
+lockInternal();
 try {
-lock();
 super.setAuthType(authType);
 if (addDeltaRequest) {
 deltaRequest.setAuthType(authType);
 }
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -496,12 +504,12 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
   

[tomcat] 02/06: Refactor to remove use of session#lock and #unlock in the DeltaManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 4e2384dc59c9d7e98a430a75e090e625dcfca808
Author: Mark Thomas 
AuthorDate: Tue May 21 21:57:03 2019 +0100

Refactor to remove use of session#lock and #unlock in the DeltaManager
---
 .../catalina/ha/session/ClusterManagerBase.java| 21 ++-
 .../apache/catalina/ha/session/DeltaManager.java   | 28 ++--
 .../apache/catalina/ha/session/DeltaSession.java   | 30 ++
 3 files changed, 59 insertions(+), 20 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java 
b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index 475f7bf..89121aa 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -5,9 +5,9 @@
  * The ASF licenses this file to You under the Apache License, Version 2.0
  * (the "License"); you may not use this file except in compliance with
  * the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -33,9 +33,10 @@ import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 
 /**
- * 
+ *
  * @author Filip Hanik
  */
 public abstract class ClusterManagerBase extends ManagerBase
@@ -63,6 +64,14 @@ public abstract class ClusterManagerBase extends ManagerBase
  */
 private boolean recordAllActions = false;
 
+private SynchronizedStack deltaRequestPool = new 
SynchronizedStack();
+
+
+protected SynchronizedStack getDeltaRequestPool() {
+return deltaRequestPool;
+}
+
+
 @Override
 public CatalinaCluster getCluster() {
 return cluster;
@@ -164,7 +173,7 @@ public abstract class ClusterManagerBase extends ManagerBase
 public ReplicationStream getReplicationStream(byte[] data, int offset, int 
length) throws IOException {
 ByteArrayInputStream fis = new ByteArrayInputStream(data, offset, 
length);
 return new ReplicationStream(fis, getClassLoaders());
-}
+}
 
 
 //   persistence 
handler
@@ -175,7 +184,7 @@ public abstract class ClusterManagerBase extends ManagerBase
  */
 @Override
 public void load() {
-// NOOP 
+// NOOP
 }
 
 /**
@@ -229,7 +238,7 @@ public abstract class ClusterManagerBase extends ManagerBase
 
 if(replicationValve == null && log.isDebugEnabled()) {
 log.debug("no ReplicationValve found for CrossContext 
Support");
-}//endif 
+}//endif
 }//end if
 }//endif
 }//end if
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index d7b86ab..84a3b16 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -99,7 +99,6 @@ public class DeltaManager extends ClusterManagerBase{
 private boolean receiverQueue = false ;
 private boolean stateTimestampDrop = true ;
 private volatile long stateTransferCreateSendTime;
-private SynchronizedStack deltaRequestPool = new 
SynchronizedStack();
 
 // -- 
stats attributes
 
@@ -562,17 +561,23 @@ public class DeltaManager extends ClusterManagerBase{
  * @param session
  * @param data message data
  * @return The request
- * @throws ClassNotFoundException
- * @throws IOException
+ * @throws ClassNotFoundException Serialization error
+ * @throws IOException IO error with serialization
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10.
+ * Calling this method may result in a deadlock. See:
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
  */
-protected DeltaRequest deserializeDeltaRequest(DeltaSession session, 
byte[] data) throws ClassNotFoundException, IOException {
+@Deprecated
+protected DeltaRequest deserializeDeltaRequest(DeltaSession session, 
byte[] data)
+throws ClassNotFoundException, IOException {
+session.lock();
 try {
-session.lock();
 ReplicationStream ois = getReplicationStream(data);
 session.getDeltaRequest().readExternal(ois);
 ois.close();
   

[tomcat] 01/06: Extra fixes for https://bz.apache.org/bugzilla/show_bug.cgi?id=62841

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 1cf99ac28d4c3af5b309eabc0393fcede414100e
Author: Mark Thomas 
AuthorDate: Tue May 21 13:38:08 2019 +0100

Extra fixes for https://bz.apache.org/bugzilla/show_bug.cgi?id=62841

Thanks to kfujino's review
---
 java/org/apache/catalina/ha/session/DeltaManager.java | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 0e2a7e7..d7b86ab 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -583,13 +583,19 @@ public class DeltaManager extends ClusterManagerBase{
  *
  * @param deltaRequest
  * @return serialized delta request
- * @throws IOException
+ * @throws IOException IO error with serialization
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10.
+ * Calling this method may result in a deadlock. See:
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
  */
-protected byte[] serializeDeltaRequest(DeltaSession session, DeltaRequest 
deltaRequest) throws IOException {
+@Deprecated
+protected byte[] serializeDeltaRequest(DeltaSession session, DeltaRequest 
deltaRequest)
+throws IOException {
+session.lock();
 try {
-session.lock();
 return deltaRequest.serialize();
-}finally {
+} finally {
 session.unlock();
 }
 }
@@ -976,7 +982,7 @@ public class DeltaManager extends ClusterManagerBase{
 deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
 if (deltaRequest.getSize() > 0) {
 counterSend_EVT_SESSION_DELTA++;
-byte[] data = serializeDeltaRequest(session,deltaRequest);
+byte[] data = deltaRequest.serialize();
 msg = new SessionMessageImpl(getName(),
  SessionMessage.EVT_SESSION_DELTA,
  data,


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



[tomcat] branch 7.0.x updated (c043c29 -> 6421a8c)

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from c043c29  Fix rare potential NPE identified by Coverity Scan.
 new 1cf99ac  Extra fixes for 
https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
 new 4e2384d  Refactor to remove use of session#lock and #unlock in the 
DeltaManager
 new 020b849  Refactor to create internal lock methods.
 new 3a34cfb  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 
BackupManager
 new b199c4b  Ensure DeltaRequest is created with correct recordAllActions 
value
 new 6421a8c  Refactor #requestCompleted to re-use DeltaSession#getDiff()

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../catalina/ha/session/ClusterManagerBase.java|  21 ++-
 .../apache/catalina/ha/session/DeltaManager.java   |  60 
 .../apache/catalina/ha/session/DeltaSession.java   | 159 +++--
 3 files changed, 155 insertions(+), 85 deletions(-)


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



[tomcat] 05/06: Ensure DeltaRequest is created with correct recordAllActions value

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b199c4beffc8527f627e47f4474e0a10055ab688
Author: Mark Thomas 
AuthorDate: Wed May 22 09:11:43 2019 +0100

Ensure DeltaRequest is created with correct recordAllActions value
---
 java/org/apache/catalina/ha/session/DeltaManager.java | 2 +-
 java/org/apache/catalina/ha/session/DeltaSession.java | 8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 84a3b16..25b3f96 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -983,7 +983,7 @@ public class DeltaManager extends ClusterManagerBase{
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
 // Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
 }
 deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
 if (deltaRequest.getSize() > 0) {
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 35d17d8..4cf78b3 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -144,8 +144,10 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 if (manager instanceof ClusterManagerBase) {
 deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
 newDeltaRequest = deltaRequestPool.pop();
-}
-if (newDeltaRequest == null) {
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
+}
+} else {
 newDeltaRequest = new DeltaRequest();
 }
 
@@ -687,7 +689,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
 }
 
 ReplicationStream ois = ((ClusterManagerBase) 
manager).getReplicationStream(delta);


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



[tomcat] 04/06: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 7.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3a34cfb3bad9b3ef26d11fbb16916b96146aeab2
Author: Mark Thomas 
AuthorDate: Tue May 21 22:35:16 2019 +0100

Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

Expand the fix to the BackupManager by refactoring the locking into the
DeltaSession and ensuring that the session is not locked during
serialization.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 51 +-
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 08f0cd2..35d17d8 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -138,12 +138,29 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-lockInternal();
-try {
-return getDeltaRequest().serialize();
-} finally {
-unlockInternal();
+SynchronizedStack deltaRequestPool = null;
+DeltaRequest newDeltaRequest = null;
+
+if (manager instanceof ClusterManagerBase) {
+deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
+newDeltaRequest = deltaRequestPool.pop();
 }
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest();
+}
+
+DeltaRequest oldDeltaRequest = replaceDeltaRequest(newDeltaRequest);
+
+byte[] result = oldDeltaRequest.serialize();
+
+if (deltaRequestPool != null) {
+// Only need to reset the old request if it is going to be pooled.
+// Otherwise let GC do its thing.
+oldDeltaRequest.reset();
+deltaRequestPool.push(oldDeltaRequest);
+}
+
+return result;
 }
 
 public ClassLoader[] getClassLoaders() {
@@ -188,32 +205,46 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 /**
- * Resets the current diff state and resets the dirty flag
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. The diff is reset in {@link #getDiff()}.
  */
 @Override
 public void resetDiff() {
 resetDeltaRequest();
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required locking takes place in the
+ * methods that make modifications.
+ */
 @Override
 public void lock() {
-lockInternal();
+// NO-OP
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required unlocking takes place in 
the
+ * methods that make modifications.
+ */
 @Override
 public void unlock() {
-unlockInternal();
+// NO-OP
 }
 
 /**
- * Lock during serialization
+ * Lock during serialization.
  */
 private void lockInternal() {
 diffLock.lock();
 }
 
 /**
- * Unlock after serialization
+ * Unlock after serialization.
  */
 private void unlockInternal() {
 diffLock.unlock();


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



[tomcat] 02/06: Refactor to remove use of session#lock and #unlock in the DeltaManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 10d32690f49da2a1f94cd30148a760782d994b31
Author: Mark Thomas 
AuthorDate: Tue May 21 21:57:03 2019 +0100

Refactor to remove use of session#lock and #unlock in the DeltaManager
---
 .../catalina/ha/session/ClusterManagerBase.java|  9 +++
 .../apache/catalina/ha/session/DeltaManager.java   | 17 ++--
 .../apache/catalina/ha/session/DeltaSession.java   | 31 ++
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java 
b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index 9935c67..08a6763 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -32,6 +32,7 @@ import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 
 public abstract class ClusterManagerBase extends ManagerBase implements 
ClusterManager {
 
@@ -57,6 +58,14 @@ public abstract class ClusterManagerBase extends ManagerBase 
implements ClusterM
  */
 private boolean recordAllActions = false;
 
+private SynchronizedStack deltaRequestPool = new 
SynchronizedStack<>();
+
+
+protected SynchronizedStack getDeltaRequestPool() {
+return deltaRequestPool;
+}
+
+
 @Override
 public CatalinaCluster getCluster() {
 return cluster;
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index abfad42..295066c 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -95,7 +95,6 @@ public class DeltaManager extends ClusterManagerBase{
 private boolean receiverQueue = false ;
 private boolean stateTimestampDrop = true ;
 private volatile long stateTransferCreateSendTime;
-private SynchronizedStack deltaRequestPool = new 
SynchronizedStack<>();
 
 //  stats 
attributes
 
@@ -569,7 +568,12 @@ public class DeltaManager extends ClusterManagerBase{
  * @return The request
  * @throws ClassNotFoundException Serialization error
  * @throws IOException IO error with serialization
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10.
+ * Calling this method may result in a deadlock. See:
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
  */
+@Deprecated
 protected DeltaRequest deserializeDeltaRequest(DeltaSession session, 
byte[] data)
 throws ClassNotFoundException, IOException {
 session.lock();
@@ -970,6 +974,7 @@ public class DeltaManager extends ClusterManagerBase{
 public ClusterMessage requestCompleted(String sessionId, boolean expires) {
 DeltaSession session = null;
 SessionMessage msg = null;
+SynchronizedStack deltaRequestPool = 
getDeltaRequestPool();
 DeltaRequest deltaRequest = null;
 try {
 session = (DeltaSession) findSession(sessionId);
@@ -1258,14 +1263,8 @@ public class DeltaManager extends ClusterManagerBase{
 log.debug(sm.getString("deltaManager.receiveMessage.delta",
 getName(), msg.getSessionID()));
 }
-session.lock();
-try {
-DeltaRequest dreq = deserializeDeltaRequest(session, delta);
-dreq.execute(session, isNotifyListenersOnReplication());
-session.setPrimarySession(false);
-} finally {
-session.unlock();
-}
+
+session.deserializeAndExecuteDeltaRequest(delta);
 }
 }
 
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 7604ebd..898d1a9 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -41,9 +41,11 @@ import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.ClusterSession;
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.session.StandardSession;
+import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.tribes.tipis.ReplicatedMapEntry;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -627,6 +629,35 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 
+protected 

[tomcat] branch 8.5.x updated (f02fe40 -> 529958d)

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from f02fe40  Implement same-site cookie header. Patch provided by John 
Kelly.
 new c9eb9e6  Extra fixes for 
https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
 new 10d3269  Refactor to remove use of session#lock and #unlock in the 
DeltaManager
 new 6584442  Refactor to create internal lock methods.
 new 0bbaf88  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 
BackupManager
 new bd78f15  Ensure DeltaRequest is created with correct recordAllActions 
value
 new 529958d  Refactor #requestCompleted to re-use DeltaSession#getDiff()

The 6 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../catalina/ha/session/ClusterManagerBase.java|   9 ++
 .../apache/catalina/ha/session/DeltaManager.java   |  40 ++
 .../apache/catalina/ha/session/DeltaSession.java   | 146 +++--
 3 files changed, 132 insertions(+), 63 deletions(-)


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



[tomcat] 05/06: Ensure DeltaRequest is created with correct recordAllActions value

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit bd78f15d7c0e04d0f5d037898c95355830616b4e
Author: Mark Thomas 
AuthorDate: Wed May 22 09:11:43 2019 +0100

Ensure DeltaRequest is created with correct recordAllActions value
---
 java/org/apache/catalina/ha/session/DeltaManager.java | 2 +-
 java/org/apache/catalina/ha/session/DeltaSession.java | 8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 295066c..e0ddb82 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -986,7 +986,7 @@ public class DeltaManager extends ClusterManagerBase{
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
 // Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
 }
 deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
 if (deltaRequest.getSize() > 0) {
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index b5fa5a2..72a93ca 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -143,8 +143,10 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 if (manager instanceof ClusterManagerBase) {
 deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
 newDeltaRequest = deltaRequestPool.pop();
-}
-if (newDeltaRequest == null) {
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
+}
+} else {
 newDeltaRequest = new DeltaRequest();
 }
 
@@ -675,7 +677,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
 }
 
 ReplicationStream ois = ((ClusterManagerBase) 
manager).getReplicationStream(delta);


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



[tomcat] 03/06: Refactor to create internal lock methods.

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 658444244cbe01df02bdd10f4856a79fc5a84f77
Author: Mark Thomas 
AuthorDate: Tue May 21 22:02:40 2019 +0100

Refactor to create internal lock methods.

This is a step on the path to making ReplicatedMapEntry#lock() and
unlock() NO-OPs.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 80 --
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 898d1a9..9609e24 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -137,11 +137,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-lock();
+lockInternal();
 try {
 return getDeltaRequest().serialize();
 } finally{
-unlock();
+unlockInternal();
 }
 }
 
@@ -164,7 +164,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public void applyDiff(byte[] diff, int offset, int length) throws 
IOException, ClassNotFoundException {
-lock();
+lockInternal();
 try (ObjectInputStream stream = ((ClusterManager) 
getManager()).getReplicationStream(diff, offset, length)) {
 ClassLoader contextLoader = 
Thread.currentThread().getContextClassLoader();
 try {
@@ -177,7 +177,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 Thread.currentThread().setContextClassLoader(contextLoader);
 }
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -189,19 +189,27 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 resetDeltaRequest();
 }
 
+@Override
+public void lock() {
+lockInternal();
+}
+
+@Override
+public void unlock() {
+unlockInternal();
+}
+
 /**
  * Lock during serialization
  */
-@Override
-public void lock() {
+private void lockInternal() {
 diffLock.lock();
 }
 
 /**
  * Unlock after serialization
  */
-@Override
-public void unlock() {
+private void unlockInternal() {
 diffLock.unlock();
 }
 
@@ -296,11 +304,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setMaxInactiveInterval(int interval, boolean addDeltaRequest) {
 super.maxInactiveInterval = interval;
 if (addDeltaRequest) {
-lock();
+lockInternal();
 try {
 deltaRequest.setMaxInactiveInterval(interval);
 } finally{
-unlock();
+unlockInternal();
 }
 }
 }
@@ -319,11 +327,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setNew(boolean isNew, boolean addDeltaRequest) {
 super.setNew(isNew);
 if (addDeltaRequest){
-lock();
+lockInternal();
 try {
 deltaRequest.setNew(isNew);
 } finally{
-unlock();
+unlockInternal();
 }
 }
 }
@@ -343,13 +351,13 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setPrincipal(Principal principal, boolean addDeltaRequest) {
-lock();
+lockInternal();
 try {
 super.setPrincipal(principal);
 if (addDeltaRequest)
 deltaRequest.setPrincipal(principal);
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -365,14 +373,14 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setAuthType(String authType, boolean addDeltaRequest) {
-lock();
+lockInternal();
 try {
 super.setAuthType(authType);
 if (addDeltaRequest) {
 deltaRequest.setAuthType(authType);
 }
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -484,12 +492,12 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public void recycle() {
-lock();
+lockInternal();
 try {
 super.recycle();
 deltaRequest.clear();
 } finally{
-unlock();
+unlockInternal();
 }
 }
 
@@ -512,14 +520,14 @@ public class 

[tomcat] 04/06: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0bbaf88a748c52d2a56e1736dfb5ecd109f5954f
Author: Mark Thomas 
AuthorDate: Tue May 21 22:35:16 2019 +0100

Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

Expand the fix to the BackupManager by refactoring the locking into the
DeltaSession and ensuring that the session is not locked during
serialization.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 51 +-
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 9609e24..b5fa5a2 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -137,12 +137,29 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-lockInternal();
-try {
-return getDeltaRequest().serialize();
-} finally{
-unlockInternal();
+SynchronizedStack deltaRequestPool = null;
+DeltaRequest newDeltaRequest = null;
+
+if (manager instanceof ClusterManagerBase) {
+deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
+newDeltaRequest = deltaRequestPool.pop();
 }
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest();
+}
+
+DeltaRequest oldDeltaRequest = replaceDeltaRequest(newDeltaRequest);
+
+byte[] result = oldDeltaRequest.serialize();
+
+if (deltaRequestPool != null) {
+// Only need to reset the old request if it is going to be pooled.
+// Otherwise let GC do its thing.
+oldDeltaRequest.reset();
+deltaRequestPool.push(oldDeltaRequest);
+}
+
+return result;
 }
 
 public ClassLoader[] getClassLoaders() {
@@ -182,32 +199,46 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 /**
- * Resets the current diff state and resets the dirty flag
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. The diff is reset in {@link #getDiff()}.
  */
 @Override
 public void resetDiff() {
 resetDeltaRequest();
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required locking takes place in the
+ * methods that make modifications.
+ */
 @Override
 public void lock() {
-lockInternal();
+// NO-OP
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required unlocking takes place in 
the
+ * methods that make modifications.
+ */
 @Override
 public void unlock() {
-unlockInternal();
+// NO-OP
 }
 
 /**
- * Lock during serialization
+ * Lock during serialization.
  */
 private void lockInternal() {
 diffLock.lock();
 }
 
 /**
- * Unlock after serialization
+ * Unlock after serialization.
  */
 private void unlockInternal() {
 diffLock.unlock();


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



[tomcat] 06/06: Refactor #requestCompleted to re-use DeltaSession#getDiff()

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 529958dd0012d00e7aa1c51ccfa6b4d64ccef7f2
Author: Mark Thomas 
AuthorDate: Wed May 22 12:07:35 2019 +0100

Refactor #requestCompleted to re-use DeltaSession#getDiff()
---
 .../org/apache/catalina/ha/session/DeltaManager.java | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index e0ddb82..cce8840 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -39,7 +39,6 @@ import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -974,8 +973,6 @@ public class DeltaManager extends ClusterManagerBase{
 public ClusterMessage requestCompleted(String sessionId, boolean expires) {
 DeltaSession session = null;
 SessionMessage msg = null;
-SynchronizedStack deltaRequestPool = 
getDeltaRequestPool();
-DeltaRequest deltaRequest = null;
 try {
 session = (DeltaSession) findSession(sessionId);
 if (session == null) {
@@ -983,18 +980,11 @@ public class DeltaManager extends ClusterManagerBase{
 // removed the session from the Manager.
 return null;
 }
-DeltaRequest newDeltaRequest = deltaRequestPool.pop();
-if (newDeltaRequest == null) {
-// Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
-}
-deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
-if (deltaRequest.getSize() > 0) {
+if (session.isDirty()) {
 counterSend_EVT_SESSION_DELTA++;
-byte[] data = deltaRequest.serialize();
 msg = new SessionMessageImpl(getName(),
  SessionMessage.EVT_SESSION_DELTA,
- data,
+ session.getDiff(),
  sessionId,
  sessionId + "-" + 
System.currentTimeMillis());
 }
@@ -1002,12 +992,6 @@ public class DeltaManager extends ClusterManagerBase{
 
log.error(sm.getString("deltaManager.createMessage.unableCreateDeltaRequest",
 sessionId), x);
 return null;
-} finally {
-if (deltaRequest != null) {
-// Reset the instance before it is returned to the pool
-deltaRequest.reset();
-deltaRequestPool.push(deltaRequest);
-}
 }
 if(msg == null) {
 if(!expires && !session.isPrimarySession()) {


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



[tomcat] 01/06: Extra fixes for https://bz.apache.org/bugzilla/show_bug.cgi?id=62841

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit c9eb9e6d72b9e73f040966c4ccc81174555624a6
Author: Mark Thomas 
AuthorDate: Tue May 21 13:38:08 2019 +0100

Extra fixes for https://bz.apache.org/bugzilla/show_bug.cgi?id=62841

Thanks to kfujino's review
---
 java/org/apache/catalina/ha/session/DeltaManager.java | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 45588ae..abfad42 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -591,7 +591,12 @@ public class DeltaManager extends ClusterManagerBase{
  * @param deltaRequest The request to serialize
  * @return serialized delta request
  * @throws IOException IO error with serialization
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10.
+ * Calling this method may result in a deadlock. See:
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
  */
+@Deprecated
 protected byte[] serializeDeltaRequest(DeltaSession session, DeltaRequest 
deltaRequest)
 throws IOException {
 session.lock();
@@ -981,7 +986,7 @@ public class DeltaManager extends ClusterManagerBase{
 deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
 if (deltaRequest.getSize() > 0) {
 counterSend_EVT_SESSION_DELTA++;
-byte[] data = serializeDeltaRequest(session,deltaRequest);
+byte[] data = deltaRequest.serialize();
 msg = new SessionMessageImpl(getName(),
  SessionMessage.EVT_SESSION_DELTA,
  data,


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



[tomcat] 02/05: Refactor to create internal lock methods.

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 28473488e48d8e90ce49556d8117006719de540c
Author: Mark Thomas 
AuthorDate: Tue May 21 22:02:40 2019 +0100

Refactor to create internal lock methods.

This is a step on the path to making ReplicatedMapEntry#lock() and
unlock() NO-OPs.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 80 --
 1 file changed, 44 insertions(+), 36 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 4d14425..07b4cca 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -138,11 +138,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-lock();
+lockInternal();
 try {
 return getDeltaRequest().serialize();
 } finally{
-unlock();
+unlockInternal();
 }
 }
 
@@ -165,7 +165,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public void applyDiff(byte[] diff, int offset, int length) throws 
IOException, ClassNotFoundException {
-lock();
+lockInternal();
 try (ObjectInputStream stream = ((ClusterManager) 
getManager()).getReplicationStream(diff, offset, length)) {
 ClassLoader contextLoader = 
Thread.currentThread().getContextClassLoader();
 try {
@@ -178,7 +178,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 Thread.currentThread().setContextClassLoader(contextLoader);
 }
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -190,19 +190,27 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 resetDeltaRequest();
 }
 
+@Override
+public void lock() {
+lockInternal();
+}
+
+@Override
+public void unlock() {
+unlockInternal();
+}
+
 /**
  * Lock during serialization
  */
-@Override
-public void lock() {
+private void lockInternal() {
 diffLock.lock();
 }
 
 /**
  * Unlock after serialization
  */
-@Override
-public void unlock() {
+private void unlockInternal() {
 diffLock.unlock();
 }
 
@@ -297,11 +305,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setMaxInactiveInterval(int interval, boolean addDeltaRequest) {
 super.maxInactiveInterval = interval;
 if (addDeltaRequest) {
-lock();
+lockInternal();
 try {
 deltaRequest.setMaxInactiveInterval(interval);
 } finally{
-unlock();
+unlockInternal();
 }
 }
 }
@@ -320,11 +328,11 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 public void setNew(boolean isNew, boolean addDeltaRequest) {
 super.setNew(isNew);
 if (addDeltaRequest){
-lock();
+lockInternal();
 try {
 deltaRequest.setNew(isNew);
 } finally{
-unlock();
+unlockInternal();
 }
 }
 }
@@ -344,13 +352,13 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setPrincipal(Principal principal, boolean addDeltaRequest) {
-lock();
+lockInternal();
 try {
 super.setPrincipal(principal);
 if (addDeltaRequest)
 deltaRequest.setPrincipal(principal);
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -366,14 +374,14 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 public void setAuthType(String authType, boolean addDeltaRequest) {
-lock();
+lockInternal();
 try {
 super.setAuthType(authType);
 if (addDeltaRequest) {
 deltaRequest.setAuthType(authType);
 }
 } finally {
-unlock();
+unlockInternal();
 }
 }
 
@@ -486,12 +494,12 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public void recycle() {
-lock();
+lockInternal();
 try {
 super.recycle();
 deltaRequest.clear();
 } finally{
-unlock();
+unlockInternal();
 }
 }
 
@@ -514,14 +522,14 @@ public class 

[tomcat] 03/05: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit bcf1b79959febb21dbc947d06873251f3a02d758
Author: Mark Thomas 
AuthorDate: Tue May 21 22:35:16 2019 +0100

Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 BackupManager

Expand the fix to the BackupManager by refactoring the locking into the
DeltaSession and ensuring that the session is not locked during
serialization.
---
 .../apache/catalina/ha/session/DeltaSession.java   | 51 +-
 1 file changed, 41 insertions(+), 10 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 07b4cca..d9afe90 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -138,12 +138,29 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
  */
 @Override
 public byte[] getDiff() throws IOException {
-lockInternal();
-try {
-return getDeltaRequest().serialize();
-} finally{
-unlockInternal();
+SynchronizedStack deltaRequestPool = null;
+DeltaRequest newDeltaRequest = null;
+
+if (manager instanceof ClusterManagerBase) {
+deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
+newDeltaRequest = deltaRequestPool.pop();
 }
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest();
+}
+
+DeltaRequest oldDeltaRequest = replaceDeltaRequest(newDeltaRequest);
+
+byte[] result = oldDeltaRequest.serialize();
+
+if (deltaRequestPool != null) {
+// Only need to reset the old request if it is going to be pooled.
+// Otherwise let GC do its thing.
+oldDeltaRequest.reset();
+deltaRequestPool.push(oldDeltaRequest);
+}
+
+return result;
 }
 
 public ClassLoader[] getClassLoaders() {
@@ -183,32 +200,46 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 /**
- * Resets the current diff state and resets the dirty flag
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. The diff is reset in {@link #getDiff()}.
  */
 @Override
 public void resetDiff() {
 resetDeltaRequest();
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required locking takes place in the
+ * methods that make modifications.
+ */
 @Override
 public void lock() {
-lockInternal();
+// NO-OP
 }
 
+/**
+ * {@inheritDoc}
+ * 
+ * This implementation is a NO-OP. Any required unlocking takes place in 
the
+ * methods that make modifications.
+ */
 @Override
 public void unlock() {
-unlockInternal();
+// NO-OP
 }
 
 /**
- * Lock during serialization
+ * Lock during serialization.
  */
 private void lockInternal() {
 diffLock.lock();
 }
 
 /**
- * Unlock after serialization
+ * Unlock after serialization.
  */
 private void unlockInternal() {
 diffLock.unlock();


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



[tomcat] 05/05: Refactor #requestCompleted to re-use DeltaSession#getDiff()

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 547fb246149d828279cb7cdf7193165f7ef9985d
Author: Mark Thomas 
AuthorDate: Wed May 22 12:07:35 2019 +0100

Refactor #requestCompleted to re-use DeltaSession#getDiff()
---
 .../org/apache/catalina/ha/session/DeltaManager.java | 20 ++--
 1 file changed, 2 insertions(+), 18 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 29ed8d2..3ee3fbe 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -39,7 +39,6 @@ import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
 import org.apache.tomcat.util.ExceptionUtils;
-import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -966,8 +965,6 @@ public class DeltaManager extends ClusterManagerBase{
 public ClusterMessage requestCompleted(String sessionId, boolean expires) {
 DeltaSession session = null;
 SessionMessage msg = null;
-SynchronizedStack deltaRequestPool = 
getDeltaRequestPool();
-DeltaRequest deltaRequest = null;
 try {
 session = (DeltaSession) findSession(sessionId);
 if (session == null) {
@@ -975,18 +972,11 @@ public class DeltaManager extends ClusterManagerBase{
 // removed the session from the Manager.
 return null;
 }
-DeltaRequest newDeltaRequest = deltaRequestPool.pop();
-if (newDeltaRequest == null) {
-// Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
-}
-deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
-if (deltaRequest.getSize() > 0) {
+if (session.isDirty()) {
 counterSend_EVT_SESSION_DELTA++;
-byte[] data = deltaRequest.serialize();
 msg = new SessionMessageImpl(getName(),
  SessionMessage.EVT_SESSION_DELTA,
- data,
+ session.getDiff(),
  sessionId,
  sessionId + "-" + 
System.currentTimeMillis());
 }
@@ -994,12 +984,6 @@ public class DeltaManager extends ClusterManagerBase{
 
log.error(sm.getString("deltaManager.createMessage.unableCreateDeltaRequest",
 sessionId), x);
 return null;
-} finally {
-if (deltaRequest != null) {
-// Reset the instance before it is returned to the pool
-deltaRequest.reset();
-deltaRequestPool.push(deltaRequest);
-}
 }
 if(msg == null) {
 if(!expires && !session.isPrimarySession()) {


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



[tomcat] 01/05: Refactor to remove use of session#lock and #unlock in the DeltaManager

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 6d8c383e42442bd84a0d0be64098ab5bb0d691e8
Author: Mark Thomas 
AuthorDate: Tue May 21 21:57:03 2019 +0100

Refactor to remove use of session#lock and #unlock in the DeltaManager
---
 .../catalina/ha/session/ClusterManagerBase.java|  9 +++
 .../apache/catalina/ha/session/DeltaManager.java   | 17 ++--
 .../apache/catalina/ha/session/DeltaSession.java   | 31 ++
 3 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/ClusterManagerBase.java 
b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
index 9935c67..08a6763 100644
--- a/java/org/apache/catalina/ha/session/ClusterManagerBase.java
+++ b/java/org/apache/catalina/ha/session/ClusterManagerBase.java
@@ -32,6 +32,7 @@ import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 
 public abstract class ClusterManagerBase extends ManagerBase implements 
ClusterManager {
 
@@ -57,6 +58,14 @@ public abstract class ClusterManagerBase extends ManagerBase 
implements ClusterM
  */
 private boolean recordAllActions = false;
 
+private SynchronizedStack deltaRequestPool = new 
SynchronizedStack<>();
+
+
+protected SynchronizedStack getDeltaRequestPool() {
+return deltaRequestPool;
+}
+
+
 @Override
 public CatalinaCluster getCluster() {
 return cluster;
diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 136c549..6c5b3bd 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -89,7 +89,6 @@ public class DeltaManager extends ClusterManagerBase{
 private boolean receiverQueue = false ;
 private boolean stateTimestampDrop = true ;
 private volatile long stateTransferCreateSendTime;
-private SynchronizedStack deltaRequestPool = new 
SynchronizedStack<>();
 
 //  stats 
attributes
 
@@ -563,7 +562,12 @@ public class DeltaManager extends ClusterManagerBase{
  * @return The request
  * @throws ClassNotFoundException Serialization error
  * @throws IOException IO error with serialization
+ *
+ * @deprecated Unused. This will be removed in Tomcat 10.
+ * Calling this method may result in a deadlock. See:
+ * https://bz.apache.org/bugzilla/show_bug.cgi?id=62841
  */
+@Deprecated
 protected DeltaRequest deserializeDeltaRequest(DeltaSession session, 
byte[] data)
 throws ClassNotFoundException, IOException {
 session.lock();
@@ -962,6 +966,7 @@ public class DeltaManager extends ClusterManagerBase{
 public ClusterMessage requestCompleted(String sessionId, boolean expires) {
 DeltaSession session = null;
 SessionMessage msg = null;
+SynchronizedStack deltaRequestPool = 
getDeltaRequestPool();
 DeltaRequest deltaRequest = null;
 try {
 session = (DeltaSession) findSession(sessionId);
@@ -1250,14 +1255,8 @@ public class DeltaManager extends ClusterManagerBase{
 log.debug(sm.getString("deltaManager.receiveMessage.delta",
 getName(), msg.getSessionID()));
 }
-session.lock();
-try {
-DeltaRequest dreq = deserializeDeltaRequest(session, delta);
-dreq.execute(session, isNotifyListenersOnReplication());
-session.setPrimarySession(false);
-} finally {
-session.unlock();
-}
+
+session.deserializeAndExecuteDeltaRequest(delta);
 }
 }
 
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index 4b71647..4d14425 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -42,9 +42,11 @@ import org.apache.catalina.ha.ClusterMessage;
 import org.apache.catalina.ha.ClusterSession;
 import org.apache.catalina.session.ManagerBase;
 import org.apache.catalina.session.StandardSession;
+import org.apache.catalina.tribes.io.ReplicationStream;
 import org.apache.catalina.tribes.tipis.ReplicatedMapEntry;
 import org.apache.juli.logging.Log;
 import org.apache.juli.logging.LogFactory;
+import org.apache.tomcat.util.collections.SynchronizedStack;
 import org.apache.tomcat.util.res.StringManager;
 
 /**
@@ -629,6 +631,35 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 }
 
 
+protected 

[tomcat] 04/05: Ensure DeltaRequest is created with correct recordAllActions value

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 46678701d03afa5f254705da15c6232bc2fb88be
Author: Mark Thomas 
AuthorDate: Wed May 22 09:11:43 2019 +0100

Ensure DeltaRequest is created with correct recordAllActions value
---
 java/org/apache/catalina/ha/session/DeltaManager.java | 2 +-
 java/org/apache/catalina/ha/session/DeltaSession.java | 8 +---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/ha/session/DeltaManager.java 
b/java/org/apache/catalina/ha/session/DeltaManager.java
index 6c5b3bd..29ed8d2 100644
--- a/java/org/apache/catalina/ha/session/DeltaManager.java
+++ b/java/org/apache/catalina/ha/session/DeltaManager.java
@@ -978,7 +978,7 @@ public class DeltaManager extends ClusterManagerBase{
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
 // Will be configured in replaceDeltaRequest()
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, isRecordAllActions());
 }
 deltaRequest = session.replaceDeltaRequest(newDeltaRequest);
 if (deltaRequest.getSize() > 0) {
diff --git a/java/org/apache/catalina/ha/session/DeltaSession.java 
b/java/org/apache/catalina/ha/session/DeltaSession.java
index d9afe90..4147fc0 100644
--- a/java/org/apache/catalina/ha/session/DeltaSession.java
+++ b/java/org/apache/catalina/ha/session/DeltaSession.java
@@ -144,8 +144,10 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 if (manager instanceof ClusterManagerBase) {
 deltaRequestPool = ((ClusterManagerBase) 
manager).getDeltaRequestPool();
 newDeltaRequest = deltaRequestPool.pop();
-}
-if (newDeltaRequest == null) {
+if (newDeltaRequest == null) {
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
+}
+} else {
 newDeltaRequest = new DeltaRequest();
 }
 
@@ -677,7 +679,7 @@ public class DeltaSession extends StandardSession 
implements Externalizable,Clus
 
 DeltaRequest newDeltaRequest = deltaRequestPool.pop();
 if (newDeltaRequest == null) {
-newDeltaRequest = new DeltaRequest();
+newDeltaRequest = new DeltaRequest(null, ((ClusterManagerBase) 
manager).isRecordAllActions());
 }
 
 ReplicationStream ois = ((ClusterManagerBase) 
manager).getReplicationStream(delta);


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



[tomcat] branch master updated (cbe9c72 -> 547fb24)

2019-05-23 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git.


from cbe9c72  Code style
 new 6d8c383  Refactor to remove use of session#lock and #unlock in the 
DeltaManager
 new 2847348  Refactor to create internal lock methods.
 new bcf1b79  Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 
BackupManager
 new 4667870  Ensure DeltaRequest is created with correct recordAllActions 
value
 new 547fb24  Refactor #requestCompleted to re-use DeltaSession#getDiff()

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../catalina/ha/session/ClusterManagerBase.java|   9 ++
 .../apache/catalina/ha/session/DeltaManager.java   |  35 ++---
 .../apache/catalina/ha/session/DeltaSession.java   | 146 +++--
 3 files changed, 127 insertions(+), 63 deletions(-)


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



Re: [tomcat] 02/03: Fix https://bz.apache.org/bugzilla/show_bug.cgi?id=62841 poss deadlock

2019-05-23 Thread Mark Thomas
On 23/05/2019 03:14, Keiichi Fujino wrote:
> 2019年5月22日(水) 20:27 Mark Thomas  >:
> 
> On 22/05/2019 07:37, Keiichi Fujino wrote:
> 
> 
> 
> > It seems that the recordAllActions flag is not set in the newly
> created
> > DeltaRequest.
> 
> I reworked the patch multiple times and forgot that for this iteration.
> Thanks for catching it. I've fixed this with an additional commit.
> 
> > There are duplicated codes in DeltaManager#requestCompleted and
> > DeltaSession#getDiff.
> > It may be able to call getDiff method in the
> DeltaManager#requestCompleted.
> 
> Good call. Fixed.
> 
> > The same is true for
> DeltaManager#deserializeAndExecuteDeltaRequest and
> > applyDiff.
> 
> I couldn't see this. There are some similarities but don't see how this
> could work.
> 
> The unit tests passed so I plan to commit (and back-port) this unless
> there are objections.
> 
> 
> I have no objection.
> Thanks.

Thanks for the review. Much appreciated.

Mark


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