Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SAML) Revert bad fix Refs: #31185 #31301

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions dotCMS/src/main/java/com/dotcms/rest/config/ContainerReloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,21 @@

import com.dotmarketing.util.Logger;
import java.util.concurrent.atomic.AtomicReference;
import javax.enterprise.context.ApplicationScoped;
import javax.ws.rs.ext.Provider;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.server.spi.AbstractContainerLifecycleListener;
import org.glassfish.jersey.server.spi.Container;

/**
* A new Re-loader will get created on each reload there can only be one container at a time
* A new Reloader will get created on each reload there can only be one container at a time
*/
class ContainerReloader extends AbstractContainerLifecycleListener {

private static final ContainerReloader INSTANCE = new ContainerReloader();
@Provider
@ApplicationScoped
public class ContainerReloader extends AbstractContainerLifecycleListener {

private static final AtomicReference<Container> containerRef = new AtomicReference<>();

public static ContainerReloader getInstance() {
return INSTANCE;
}

@Override
public void onStartup(Container container) {
Logger.debug(ContainerReloader.class, "Jersey Container started");
Expand All @@ -37,10 +35,12 @@ public void onReload(Container container) {
}

public void reload() {
final Container container = containerRef.get();
if (null != container) {
Logger.debug(ContainerReloader.class, "Jersey Reloading request");
Container container = containerRef.get();
Logger.debug(ContainerReloader.class, "Jersey Reloading request");
if (container != null) {
container.reload(ResourceConfig.forApplicationClass(DotRestApplication.class));
} else {
Logger.error(ContainerReloader.class, "Jersey Container not available");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dotcms.rest.config;

import com.dotcms.cdi.CDIUtils;
import com.dotcms.telemetry.rest.TelemetryResource;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.Logger;
Expand All @@ -12,6 +13,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.media.multipart.MultiPartFeature;
Expand Down Expand Up @@ -87,7 +89,8 @@ public static synchronized void addClass(final Class<?> clazz) {
return;
}
if (Boolean.TRUE.equals(customClasses.computeIfAbsent(clazz,c -> true))) {
ContainerReloader.getInstance().reload();
final Optional<ContainerReloader> reloader = CDIUtils.getBean(ContainerReloader.class);
reloader.ifPresent(ContainerReloader::reload);
}
}

Expand All @@ -100,7 +103,8 @@ public static synchronized void removeClass(Class<?> clazz) {
return;
}
if(customClasses.remove(clazz) != null){
ContainerReloader.getInstance().reload();
final Optional<ContainerReloader> reloader = CDIUtils.getBean(ContainerReloader.class);
reloader.ifPresent(ContainerReloader::reload);
}
}

Expand Down
Loading