From 30293e953f95683d129579183d6a4e04221eb525 Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Tue, 18 Jun 2024 12:05:30 +0100 Subject: [PATCH 1/5] FISH-8672 FISH-8857 Reintroduce semantic version checks Signed-off-by: Andrew Pielage --- core/core-parent/pom.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/core-parent/pom.xml b/core/core-parent/pom.xml index e5f61149809..c22ffff42ff 100644 --- a/core/core-parent/pom.xml +++ b/core/core-parent/pom.xml @@ -642,8 +642,6 @@ io.opentelemetry.extension io.opentelemetry.instrumentation fish.payara.shaded - org.glassfish.api.invocation - org.apache.catalina.core From df2e13982f21166186c0f8fbf28ed24a13d3a514 Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Thu, 20 Jun 2024 12:15:04 +0100 Subject: [PATCH 2/5] FISH-8672 FISH-8857 Reintroduce removed variables and classes to keep semantic versioning happy Signed-off-by: Andrew Pielage --- .../apache/catalina/core/ContainerBase.java | 128 +++++++++++++++--- .../apache/catalina/core/StandardEngine.java | 2 +- .../api/invocation/ComponentInvocation.java | 36 +++-- 3 files changed, 135 insertions(+), 31 deletions(-) diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java index 2a783c96a57..049af172b5a 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java @@ -208,10 +208,19 @@ public Void run() { protected int debug = 0; + /** + * The deprecated processor delay for this component. + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBase#backgroundProcessorDelayAtomic}. + * Use {@link ContainerBase#getBackgroundProcessorDelay()} and {@link ContainerBase#setBackgroundProcessorDelay(int)} + */ + @Deprecated(forRemoval = true, since = "6.17.0") + protected int backgroundProcessorDelay = -1; + /** * The processor delay for this component. */ - protected AtomicInteger backgroundProcessorDelay = new AtomicInteger(-1); + protected AtomicInteger backgroundProcessorDelayAtomic = new AtomicInteger(-1); /** @@ -317,16 +326,32 @@ public Void run() { private Thread sessionThread = null; + /** + * The deprecated background thread completion semaphore. + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBase#threadDoneAtomic}. + */ + @Deprecated(forRemoval = true, since = "6.17.0") + private volatile boolean threadDone = false; + /** * The background thread completion semaphore. */ - private AtomicBoolean threadDone = new AtomicBoolean(); + private AtomicBoolean threadDoneAtomic = new AtomicBoolean(); + + /** + * The deprecated session background thread completion semaphore. + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBase#threadSessionDoneAtomic}. + */ + @Deprecated(forRemoval = true, since = "6.17.0") + private volatile boolean threadSessionDone = false; /** * The session background thread completion semaphore. */ - private AtomicBoolean threadSessionDone = new AtomicBoolean(); + private AtomicBoolean threadSessionDoneAtomic = new AtomicBoolean(); /** @@ -385,7 +410,7 @@ public void setDebug(int debug) { */ @Override public int getBackgroundProcessorDelay() { - return backgroundProcessorDelay.get(); + return backgroundProcessorDelayAtomic.get(); } @@ -398,7 +423,7 @@ public int getBackgroundProcessorDelay() { */ @Override public void setBackgroundProcessorDelay(int delay) { - backgroundProcessorDelay.set(delay); + backgroundProcessorDelayAtomic.set(delay); } @@ -1737,13 +1762,13 @@ protected void threadStart() { if (thread != null) return; - if (backgroundProcessorDelay.get() <= 0) + if (backgroundProcessorDelayAtomic.get() <= 0) return; - threadDone.set(false); + threadDoneAtomic.set(false); String threadName = "ContainerBackgroundProcessor[" + toString() + "]"; - thread = new Thread(new ContainerBackgroundProcessor(getMappingObject(), threadDone, - backgroundProcessorDelay), threadName); + thread = new Thread(new ContainerBackgroundProcessorAtomic(getMappingObject(), threadDoneAtomic, + backgroundProcessorDelayAtomic), threadName); thread.setDaemon(true); thread.start(); @@ -1756,10 +1781,10 @@ protected void threadStart() { protected void threadSessionStart() { if (sessionThread != null || manager == null) return; - threadSessionDone.set(false); + threadSessionDoneAtomic.set(false); String threadName = "ContainerBackgroundSessionProcessor[" + toString() + "]"; - sessionThread = new Thread(new ContainerBackgroundSessionProcessor(getMappingObject(), manager, - threadSessionDone), threadName); + sessionThread = new Thread(new ContainerBackgroundSessionProcessorAtomic(getMappingObject(), manager, + threadSessionDoneAtomic), threadName); sessionThread.setDaemon(true); sessionThread.start(); @@ -1775,7 +1800,7 @@ protected void threadStop() { if (thread == null) return; - threadDone.set(true); + threadDoneAtomic.set(true); thread.interrupt(); try { thread.join(); @@ -1796,7 +1821,7 @@ protected void threadSessionStop() { return; } - this.threadSessionDone.set(true); + this.threadSessionDoneAtomic.set(true); sessionThread.interrupt(); try { sessionThread.join(); @@ -1808,17 +1833,18 @@ protected void threadSessionStop() { // -------------------------------------- ContainerExecuteDelay Inner Class - /** * Private thread class to invoke the backgroundProcess method * of this container and its children after a fixed delay. + * + * Replaces {@link ContainerBackgroundProcessor} */ - protected static class ContainerBackgroundProcessor implements Runnable { + protected static class ContainerBackgroundProcessorAtomic implements Runnable { private final WeakReference base; private final AtomicBoolean threadDone; private final AtomicInteger backgroundProcessorDelay; - public ContainerBackgroundProcessor(Object base, + public ContainerBackgroundProcessorAtomic(Object base, AtomicBoolean threadDone, AtomicInteger backgroundProcessorDelay) { this.base = new WeakReference<>(base); this.threadDone = threadDone; @@ -1870,13 +1896,15 @@ protected void processChildren(Container container, ClassLoader cl) { /** * Thread class to invoke the backgroundSessionUpdate method * of this container and its children after 500 milliseconds. + * + * Replaces {@link ContainerBackgroundSessionProcessor} */ - protected static class ContainerBackgroundSessionProcessor implements Runnable { + protected static class ContainerBackgroundSessionProcessorAtomic implements Runnable { private final WeakReference base; private final WeakReference manager; private final AtomicBoolean threadSessionDone; - public ContainerBackgroundSessionProcessor(Object base, Manager manager, AtomicBoolean threadSessionDone) { + public ContainerBackgroundSessionProcessorAtomic(Object base, Manager manager, AtomicBoolean threadSessionDone) { this.base = new WeakReference<>(base); this.manager = new WeakReference<>(manager); this.threadSessionDone = threadSessionDone; @@ -1926,6 +1954,68 @@ protected void processChildren(Container container, ClassLoader cl) { } } + + // -------------------------------------- DEPRECATED! + /** + * Deprecated private thread class to invoke the backgroundProcess method + * of this container and its children after a fixed delay. + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBackgroundProcessorAtomic}. + */ + @Deprecated(forRemoval = true, since = "6.17.0") + protected class ContainerBackgroundProcessor implements Runnable { + + private final ContainerBackgroundProcessorAtomic containerBackgroundProcessorAtomic; + + public ContainerBackgroundProcessor() { + containerBackgroundProcessorAtomic = new ContainerBackgroundProcessorAtomic(getMappingObject(), + threadDoneAtomic, backgroundProcessorDelayAtomic); + } + + public ContainerBackgroundProcessor(ContainerBackgroundProcessorAtomic containerBackgroundProcessorAtomic) { + this.containerBackgroundProcessorAtomic = containerBackgroundProcessorAtomic; + } + + @Override + public void run() { + containerBackgroundProcessorAtomic.run(); + } + + protected void processChildren(Container container, ClassLoader cl) { + containerBackgroundProcessorAtomic.processChildren(container, cl); + } + } + + /** + * Deprecated thread class to invoke the backgroundSessionUpdate method + * of this container and its children after 500 milliseconds. + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBackgroundSessionProcessorAtomic}. + */ + @Deprecated(forRemoval = true, since = "6.17.0") + protected class ContainerBackgroundSessionProcessor implements Runnable { + + private final ContainerBackgroundSessionProcessorAtomic containerBackgroundSessionProcessorAtomic; + + public ContainerBackgroundSessionProcessor() { + containerBackgroundSessionProcessorAtomic = new ContainerBackgroundSessionProcessorAtomic( + getMappingObject(), manager, threadSessionDoneAtomic); + } + + public ContainerBackgroundSessionProcessor(ContainerBackgroundSessionProcessorAtomic containerBackgroundSessionProcessorAtomic) { + this.containerBackgroundSessionProcessorAtomic = containerBackgroundSessionProcessorAtomic; + } + + @Override + public void run() { + containerBackgroundSessionProcessorAtomic.run(); + } + + protected void processChildren(Container container, ClassLoader cl) { + containerBackgroundSessionProcessorAtomic.processChildren(container, cl); + } + + } } diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java index a2e4b53ae9d..4454c890834 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java @@ -97,7 +97,7 @@ public StandardEngine() { } catch(Exception ex) { } // By default, the engine will hold the reloading thread - backgroundProcessorDelay.set(10); + backgroundProcessorDelayAtomic.set(10); } diff --git a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java index 18130931752..2201b2f69b2 100644 --- a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java +++ b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java @@ -79,11 +79,25 @@ public enum ComponentInvocationType { private String instanceName; /** - * ServletContext for servlet, Container for EJB + * The deprecated ServletContext for servlet, Container for EJB + * + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ComponentInvocation#containerReference}. + * Use {@link ComponentInvocation#getContainer()} and {@link ComponentInvocation#setContainer(Object)} instead. + * + */ + @Deprecated(forRemoval = true, since = "6.17.0") + public Object container; // + + /** + * DO NOT USE! Retained for semantic versioning. Replaced by {@link ComponentInvocation#jndiEnvironmentReference}. + * Use {@link ComponentInvocation#getJNDIEnvironment()} and {@link ComponentInvocation#setJNDIEnvironment(Object)} instead. */ - private WeakReference container; + @Deprecated(forRemoval = true, since = "6.17.0") + public Object jndiEnvironment; + + private WeakReference containerReference; - private WeakReference jndiEnvironment; + private WeakReference jndiEnvironmentReference; public String componentId; @@ -118,13 +132,13 @@ public enum ComponentInvocationType { protected String registrationName; public ComponentInvocation() { - container = new WeakReference<>(null); + containerReference = new WeakReference<>(null); } public ComponentInvocation(String componentId, ComponentInvocationType invocationType, Object container, String appName, String moduleName, String registrationName) { this.componentId = componentId; this.invocationType = invocationType; - this.container = new WeakReference<>(container); + this.containerReference = new WeakReference<>(container); this.appName = appName; this.moduleName = moduleName; this.registrationName = registrationName; @@ -134,7 +148,7 @@ public ComponentInvocation(String componentId, ComponentInvocationType invocatio this.componentId = componentId; this.invocationType = invocationType; this.instance = instance; - this.container = new WeakReference<>(container); + this.containerReference = new WeakReference<>(container); this.transaction = transaction; } @@ -211,22 +225,22 @@ public void setJndiEnvironment(Object jndiEnvironment) { } public void setJNDIEnvironment(Object val) { - jndiEnvironment = new WeakReference<>(val); + jndiEnvironmentReference = new WeakReference<>(val); } public Object getJNDIEnvironment() { - if (jndiEnvironment == null) { + if (jndiEnvironmentReference == null) { return null; } - return jndiEnvironment.get(); + return jndiEnvironmentReference.get(); } public Object getContainer() { - return container.get(); + return containerReference.get(); } public void setContainer(Object container) { - this.container = new WeakReference<>(container); + this.containerReference = new WeakReference<>(container); } public Object getContainerContext() { From b4ab8566369ada3fe9c41765729ef70c056ae46c Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Thu, 20 Jun 2024 12:27:56 +0100 Subject: [PATCH 3/5] FISH-8672 FISH-8857 Corrections Don't need to adjust private variables Signed-off-by: Andrew Pielage --- .../apache/catalina/core/ContainerBase.java | 37 +++++-------------- .../api/invocation/ComponentInvocation.java | 2 +- 2 files changed, 11 insertions(+), 28 deletions(-) diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java index 049af172b5a..015edeac640 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java @@ -326,32 +326,15 @@ public Void run() { private Thread sessionThread = null; - /** - * The deprecated background thread completion semaphore. - * - * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBase#threadDoneAtomic}. - */ - @Deprecated(forRemoval = true, since = "6.17.0") - private volatile boolean threadDone = false; - /** * The background thread completion semaphore. */ - private AtomicBoolean threadDoneAtomic = new AtomicBoolean(); - - - /** - * The deprecated session background thread completion semaphore. - * - * DO NOT USE! Retained for semantic versioning. Replaced by {@link ContainerBase#threadSessionDoneAtomic}. - */ - @Deprecated(forRemoval = true, since = "6.17.0") - private volatile boolean threadSessionDone = false; + private AtomicBoolean threadDone = new AtomicBoolean(); /** * The session background thread completion semaphore. */ - private AtomicBoolean threadSessionDoneAtomic = new AtomicBoolean(); + private AtomicBoolean threadSessionDone = new AtomicBoolean(); /** @@ -1765,9 +1748,9 @@ protected void threadStart() { if (backgroundProcessorDelayAtomic.get() <= 0) return; - threadDoneAtomic.set(false); + threadDone.set(false); String threadName = "ContainerBackgroundProcessor[" + toString() + "]"; - thread = new Thread(new ContainerBackgroundProcessorAtomic(getMappingObject(), threadDoneAtomic, + thread = new Thread(new ContainerBackgroundProcessorAtomic(getMappingObject(), threadDone, backgroundProcessorDelayAtomic), threadName); thread.setDaemon(true); thread.start(); @@ -1781,10 +1764,10 @@ protected void threadStart() { protected void threadSessionStart() { if (sessionThread != null || manager == null) return; - threadSessionDoneAtomic.set(false); + threadSessionDone.set(false); String threadName = "ContainerBackgroundSessionProcessor[" + toString() + "]"; sessionThread = new Thread(new ContainerBackgroundSessionProcessorAtomic(getMappingObject(), manager, - threadSessionDoneAtomic), threadName); + threadSessionDone), threadName); sessionThread.setDaemon(true); sessionThread.start(); @@ -1800,7 +1783,7 @@ protected void threadStop() { if (thread == null) return; - threadDoneAtomic.set(true); + threadDone.set(true); thread.interrupt(); try { thread.join(); @@ -1821,7 +1804,7 @@ protected void threadSessionStop() { return; } - this.threadSessionDoneAtomic.set(true); + this.threadSessionDone.set(true); sessionThread.interrupt(); try { sessionThread.join(); @@ -1969,7 +1952,7 @@ protected class ContainerBackgroundProcessor implements Runnable { public ContainerBackgroundProcessor() { containerBackgroundProcessorAtomic = new ContainerBackgroundProcessorAtomic(getMappingObject(), - threadDoneAtomic, backgroundProcessorDelayAtomic); + threadDone, backgroundProcessorDelayAtomic); } public ContainerBackgroundProcessor(ContainerBackgroundProcessorAtomic containerBackgroundProcessorAtomic) { @@ -1999,7 +1982,7 @@ protected class ContainerBackgroundSessionProcessor implements Runnable { public ContainerBackgroundSessionProcessor() { containerBackgroundSessionProcessorAtomic = new ContainerBackgroundSessionProcessorAtomic( - getMappingObject(), manager, threadSessionDoneAtomic); + getMappingObject(), manager, threadSessionDone); } public ContainerBackgroundSessionProcessor(ContainerBackgroundSessionProcessorAtomic containerBackgroundSessionProcessorAtomic) { diff --git a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java index 2201b2f69b2..86e1cbd8d79 100644 --- a/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java +++ b/nucleus/common/glassfish-api/src/main/java/org/glassfish/api/invocation/ComponentInvocation.java @@ -86,7 +86,7 @@ public enum ComponentInvocationType { * */ @Deprecated(forRemoval = true, since = "6.17.0") - public Object container; // + public Object container; /** * DO NOT USE! Retained for semantic versioning. Replaced by {@link ComponentInvocation#jndiEnvironmentReference}. From fae17eb28de82fdab43839df010a34e247f64753 Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Thu, 20 Jun 2024 12:31:00 +0100 Subject: [PATCH 4/5] FISH-8672 FISH-8857 New variable doesn't need to be protected Signed-off-by: Andrew Pielage --- .../src/main/java/org/apache/catalina/core/ContainerBase.java | 2 +- .../src/main/java/org/apache/catalina/core/StandardEngine.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java index 015edeac640..da9a56e6cdb 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java @@ -220,7 +220,7 @@ public Void run() { /** * The processor delay for this component. */ - protected AtomicInteger backgroundProcessorDelayAtomic = new AtomicInteger(-1); + private AtomicInteger backgroundProcessorDelayAtomic = new AtomicInteger(-1); /** diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java index 4454c890834..53e0c218ad5 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/StandardEngine.java @@ -97,7 +97,7 @@ public StandardEngine() { } catch(Exception ex) { } // By default, the engine will hold the reloading thread - backgroundProcessorDelayAtomic.set(10); + setBackgroundProcessorDelay(10); } From 98a026973eab1d7f020f234713e3e2869a0a9cfa Mon Sep 17 00:00:00 2001 From: Andrew Pielage Date: Thu, 20 Jun 2024 12:40:37 +0100 Subject: [PATCH 5/5] FISH-8672 FISH-8857 Reintroduce set method for deprecated variable Signed-off-by: Andrew Pielage --- .../src/main/java/org/apache/catalina/core/ContainerBase.java | 1 + 1 file changed, 1 insertion(+) diff --git a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java index da9a56e6cdb..d6277fc0587 100644 --- a/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java +++ b/appserver/web/web-core/src/main/java/org/apache/catalina/core/ContainerBase.java @@ -407,6 +407,7 @@ public int getBackgroundProcessorDelay() { @Override public void setBackgroundProcessorDelay(int delay) { backgroundProcessorDelayAtomic.set(delay); + backgroundProcessorDelay = delay; }