KEYCLOAK-15498 Disable gzip encoding when themes are not cached

This commit is contained in:
stianst 2020-10-21 09:02:19 +02:00 committed by Stian Thorgersen
parent de8d2eafa3
commit 74b5143c5e
4 changed files with 12 additions and 1 deletions

View file

@ -34,6 +34,8 @@ public interface ThemeManager {
*/ */
Set<String> nameSet(Theme.Type type); Set<String> nameSet(Theme.Type type);
boolean isCacheEnabled();
void clearCache(); void clearCache();
} }

View file

@ -63,7 +63,7 @@ public class ThemeResource {
try { try {
String contentType = MimeTypeUtil.getContentType(path); String contentType = MimeTypeUtil.getContentType(path);
Theme theme = session.theme().getTheme(themeName, Theme.Type.valueOf(themType.toUpperCase())); 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; InputStream resource;
if (encodingProvider != null) { if (encodingProvider != null) {

View file

@ -93,6 +93,11 @@ public class DefaultThemeManager implements ThemeManager {
return themes; return themes;
} }
@Override
public boolean isCacheEnabled() {
return factory.isCacheEnabled();
}
@Override @Override
public void clearCache() { public void clearCache() {
factory.clearCache(); factory.clearCache();

View file

@ -69,6 +69,10 @@ public class DefaultThemeManagerFactory {
return theme; return theme;
} }
public boolean isCacheEnabled() {
return themeCache != null;
}
public void clearCache() { public void clearCache() {
if (themeCache != null) { if (themeCache != null) {
themeCache.clear(); themeCache.clear();