You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by de...@apache.org on 2017/09/17 12:29:42 UTC
[myfaces-trinidad] 04/04: Tweaking empty style nodes handling,
at Blake's suggestion. Instead of failing silently (or NPE'ing),
let's fail in a more obvious way.
This is an automated email from the ASF dual-hosted git repository.
deki pushed a commit to branch andy-trinidad-2468
in repository https://gitbox.apache.org/repos/asf/myfaces-trinidad.git
commit d19f383c44cddb585a69aed962ac021a667b2faa
Author: Andy Schwartz <an...@apache.org>
AuthorDate: Thu May 15 14:44:42 2014 +0000
Tweaking empty style nodes handling, at Blake's suggestion. Instead of failing silently (or NPE'ing), let's fail in a more obvious way.
---
.../style/cache/FileSystemStyleCache.java | 18 +++++++++++++++++-
.../trinidadinternal/resource/LoggerBundle.xrts | 3 +++
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
index 29ffcb3..e5e66f8 100644
--- a/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
+++ b/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/style/cache/FileSystemStyleCache.java
@@ -785,7 +785,12 @@ public class FileSystemStyleCache implements StyleProvider
List<StyleNode> styleNodes = _getStyleContextResolvedStyles(context, document);
if (styleNodes.isEmpty())
- return null;
+ {
+ // Historically we have failed silently here. After further thought, we
+ // decided it would be better to make some noise so that folks know
+ // that something has gone wrong.
+ _throwEmptyStyleNodes(context, document);
+ }
// This code fills in the <Selector, Style> resolvedSelectorStyleMap map.
// We use _reusableStyleMap to reuse the Style objects when possible
@@ -843,6 +848,17 @@ public class FileSystemStyleCache implements StyleProvider
shortStyleClassMap, _isCompressStyles(context), resolvedSelectorStyleMap);
return new Entry(uris, styles, icons, skinProperties);
}
+
+ private void _throwEmptyStyleNodes(
+ StyleContext context,
+ StyleSheetDocument document
+ )
+ {
+ String targetName = getTargetStyleSheetName(context, document);
+ String message = _LOG.getMessage("STYLE_ENTRY_CREATION_FAILED_NO_STYLES",
+ new Object[] {targetName});
+ throw new IllegalStateException(message);
+ }
/**
* Look in the entry cache for a compatible entry.
diff --git a/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts b/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
index 939522d..f47ea1b 100644
--- a/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
+++ b/trinidad-impl/src/main/xrts/org/apache/myfaces/trinidadinternal/resource/LoggerBundle.xrts
@@ -1242,4 +1242,7 @@ The skin {0} specified on the requestMap will be used even though the consumer''
<resource key="STYLE_ENTRY_CREATION_FAILED">Creation of style sheet {0} has failed. Will retry on next request.</resource>
+<resource key="STYLE_ENTRY_CREATION_FAILED_NO_STYLES">Creation of style sheet {0} has failed. No styles found.</resource>
+
+
</resources>
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.