Skip to content

Commit

Permalink
Merge pull request payara#6777 from Pandrex247/FISH-8857
Browse files Browse the repository at this point in the history
FISH-8672 FISH-8857 Keep Semantic Versioning Happy
  • Loading branch information
Pandrex247 committed Jul 5, 2024
1 parent f252b17 commit 025470b
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
private AtomicInteger backgroundProcessorDelayAtomic = new AtomicInteger(-1);


/**
Expand Down Expand Up @@ -322,7 +331,6 @@ public Void run() {
*/
private AtomicBoolean threadDone = new AtomicBoolean();


/**
* The session background thread completion semaphore.
*/
Expand Down Expand Up @@ -385,7 +393,7 @@ public void setDebug(int debug) {
*/
@Override
public int getBackgroundProcessorDelay() {
return backgroundProcessorDelay.get();
return backgroundProcessorDelayAtomic.get();
}


Expand All @@ -398,7 +406,8 @@ public int getBackgroundProcessorDelay() {
*/
@Override
public void setBackgroundProcessorDelay(int delay) {
backgroundProcessorDelay.set(delay);
backgroundProcessorDelayAtomic.set(delay);
backgroundProcessorDelay = delay;
}


Expand Down Expand Up @@ -1737,13 +1746,13 @@ protected void threadStart() {

if (thread != null)
return;
if (backgroundProcessorDelay.get() <= 0)
if (backgroundProcessorDelayAtomic.get() <= 0)
return;

threadDone.set(false);
String threadName = "ContainerBackgroundProcessor[" + toString() + "]";
thread = new Thread(new ContainerBackgroundProcessor(getMappingObject(), threadDone,
backgroundProcessorDelay), threadName);
thread = new Thread(new ContainerBackgroundProcessorAtomic(getMappingObject(), threadDone,
backgroundProcessorDelayAtomic), threadName);
thread.setDaemon(true);
thread.start();

Expand All @@ -1758,7 +1767,7 @@ protected void threadSessionStart() {
return;
threadSessionDone.set(false);
String threadName = "ContainerBackgroundSessionProcessor[" + toString() + "]";
sessionThread = new Thread(new ContainerBackgroundSessionProcessor(getMappingObject(), manager,
sessionThread = new Thread(new ContainerBackgroundSessionProcessorAtomic(getMappingObject(), manager,
threadSessionDone), threadName);
sessionThread.setDaemon(true);
sessionThread.start();
Expand Down Expand Up @@ -1808,17 +1817,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;
Expand Down Expand Up @@ -1870,13 +1880,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> 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;
Expand Down Expand Up @@ -1926,6 +1938,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(),
threadDone, 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, threadSessionDone);
}

public ContainerBackgroundSessionProcessor(ContainerBackgroundSessionProcessorAtomic containerBackgroundSessionProcessorAtomic) {
this.containerBackgroundSessionProcessorAtomic = containerBackgroundSessionProcessorAtomic;
}

@Override
public void run() {
containerBackgroundSessionProcessorAtomic.run();
}

protected void processChildren(Container container, ClassLoader cl) {
containerBackgroundSessionProcessorAtomic.processChildren(container, cl);
}

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public StandardEngine() {
} catch(Exception ex) {
}
// By default, the engine will hold the reloading thread
backgroundProcessorDelay.set(10);
setBackgroundProcessorDelay(10);

}

Expand Down
2 changes: 0 additions & 2 deletions core/core-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,6 @@
<exclude>io.opentelemetry.extension</exclude>
<exclude>io.opentelemetry.instrumentation</exclude>
<exclude>fish.payara.shaded</exclude>
<exclude>org.glassfish.api.invocation</exclude>
<exclude>org.apache.catalina.core</exclude>
</excludes>
</parameter>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object> container;
@Deprecated(forRemoval = true, since = "6.17.0")
public Object jndiEnvironment;

private WeakReference<Object> containerReference;

private WeakReference<Object> jndiEnvironment;
private WeakReference<Object> jndiEnvironmentReference;

public String componentId;

Expand Down Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 025470b

Please sign in to comment.