diff --git a/server-spi/src/main/java/org/keycloak/models/ThemeManager.java b/server-spi/src/main/java/org/keycloak/models/ThemeManager.java index c7f6022a17..da0cce2d53 100644 --- a/server-spi/src/main/java/org/keycloak/models/ThemeManager.java +++ b/server-spi/src/main/java/org/keycloak/models/ThemeManager.java @@ -34,6 +34,8 @@ public interface ThemeManager { */ Set nameSet(Theme.Type type); + boolean isCacheEnabled(); + void clearCache(); } diff --git a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java index e72c8b4cd7..ae413ad96e 100644 --- a/services/src/main/java/org/keycloak/services/resources/ThemeResource.java +++ b/services/src/main/java/org/keycloak/services/resources/ThemeResource.java @@ -63,7 +63,7 @@ public class ThemeResource { try { String contentType = MimeTypeUtil.getContentType(path); Theme theme = session.theme().getTheme(themeName, Theme.Type.valueOf(themType.toUpperCase())); - ResourceEncodingProvider encodingProvider = ResourceEncodingHelper.getResourceEncodingProvider(session, contentType); + ResourceEncodingProvider encodingProvider = session.theme().isCacheEnabled() ? ResourceEncodingHelper.getResourceEncodingProvider(session, contentType) : null; InputStream resource; if (encodingProvider != null) { diff --git a/services/src/main/java/org/keycloak/theme/DefaultThemeManager.java b/services/src/main/java/org/keycloak/theme/DefaultThemeManager.java index 13b20f48e7..be92e243d2 100755 --- a/services/src/main/java/org/keycloak/theme/DefaultThemeManager.java +++ b/services/src/main/java/org/keycloak/theme/DefaultThemeManager.java @@ -93,6 +93,11 @@ public class DefaultThemeManager implements ThemeManager { return themes; } + @Override + public boolean isCacheEnabled() { + return factory.isCacheEnabled(); + } + @Override public void clearCache() { factory.clearCache(); diff --git a/services/src/main/java/org/keycloak/theme/DefaultThemeManagerFactory.java b/services/src/main/java/org/keycloak/theme/DefaultThemeManagerFactory.java index 8edb3829df..3969c5d331 100644 --- a/services/src/main/java/org/keycloak/theme/DefaultThemeManagerFactory.java +++ b/services/src/main/java/org/keycloak/theme/DefaultThemeManagerFactory.java @@ -69,6 +69,10 @@ public class DefaultThemeManagerFactory { return theme; } + public boolean isCacheEnabled() { + return themeCache != null; + } + public void clearCache() { if (themeCache != null) { themeCache.clear();