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:41 UTC
[myfaces-trinidad] 03/04: Tweaking InterruptedException handling.
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 70778168ed203b4933f5e031062b11d45ab7e28f
Author: Andy Schwartz <an...@apache.org>
AuthorDate: Wed Apr 16 15:11:30 2014 +0000
Tweaking InterruptedException handling.
---
.../style/cache/FileSystemStyleCache.java | 27 +++++++++++++++++-----
1 file changed, 21 insertions(+), 6 deletions(-)
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 02734ff..29ffcb3 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
@@ -530,16 +530,19 @@ public class FileSystemStyleCache implements StyleProvider
}
catch (InterruptedException ie)
{
- // Important to restore interrupted state, even if we are going to
- // throw a runtime exception.
- interrupted = true;
-
// Our thread was either interrupted just before the get() call, or
// while waiting inside of the get(). Our retry attempt failed. We
// could carry on without a style sheet, but this will only lead to
// confusion, so we choose to fail visibly instead and hope that things
// go better on the next request.
_logAndRethrowEntryGetFailure(context, document, ie, "STYLE_ENTRY_RETRIEVAL_INTERRUPTED");
+
+ // Note that we could call Thread.currentThread().interrupt() here, but choose
+ // not to do so because a) we are effectively ending the request by throwing
+ // an exception and b) marking the thread as interrupted seems to interfere
+ // with MyFaces error handling. If thread is marked as interrupted, I am
+ // not seeing the MyFaces-generated error page - just an empty status 200
+ // response.
}
catch (ExecutionException ee)
{
@@ -556,7 +559,7 @@ public class FileSystemStyleCache implements StyleProvider
if (interrupted)
{
Thread.currentThread().interrupt();
- }
+ }
}
return null;
@@ -601,6 +604,11 @@ public class FileSystemStyleCache implements StyleProvider
*
* The message is formatted with a single parameter: the name of the target
* style sheet that we were attempting to retrieve.
+ *
+ * @param contex the current style context
+ * @param document the style sheet document
+ * @param e an exception thrown by Future.get(). This is typically
+ * either ExecutionException or InterruptedException
*/
private void _logAndRethrowEntryGetFailure(
StyleContext context,
@@ -615,6 +623,7 @@ public class FileSystemStyleCache implements StyleProvider
String targetName = getTargetStyleSheetName(context, document);
_LOG.severe(message, targetName);
+ _LOG.fine(e);
Throwable cause = e.getCause();
if (cause instanceof RuntimeException)
@@ -625,10 +634,16 @@ public class FileSystemStyleCache implements StyleProvider
{
throw (Error)cause;
}
- else
+ else if (cause instanceof Exception)
{
throw new IllegalStateException(cause);
}
+ else
+ {
+ // This is the InterruptedException case, since InterruptedExceptions
+ // don't have a cause.
+ throw new IllegalStateException(message);
+ }
}
/**
--
To stop receiving notification emails like this one, please contact
"commits@myfaces.apache.org" <co...@myfaces.apache.org>.