summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpelder2006-04-27 12:04:00 (EDT)
committer pelder2006-04-27 12:04:00 (EDT)
commit5c01c9d02ab958e5a2a4ee7d404412847caaf140 (patch)
tree454b4ff3bbcea78b6733c9d4ef96e2bb00eab7c1
parent7490691accbe94285768b8bf095c9da4d72376c5 (diff)
downloadorg.eclipse.jet-5c01c9d02ab958e5a2a4ee7d404412847caaf140.zip
org.eclipse.jet-5c01c9d02ab958e5a2a4ee7d404412847caaf140.tar.gz
org.eclipse.jet-5c01c9d02ab958e5a2a4ee7d404412847caaf140.tar.bz2
[138964] Catch JET2TagException in safe runnables rather than letting default handler get them (and log them to the Error Log). Also, convert some well understood RuntimeExceptions to JET2TagExceptions to avoid logging, and improve reporting.
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeConditionalRuntimeTag.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeContainerRuntimeTag.java6
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeCustomRuntimeTag.java16
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeEmptyRuntimeTag.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeFunctionRuntimeTag.java2
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeIteratingRuntimeTag.java4
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeOtherRuntimeTag.java8
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/AbstractJavaFileTag.java11
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/ProjectTag.java10
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java7
-rw-r--r--plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java20
12 files changed, 72 insertions, 20 deletions
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
index 506e1b9..9b4eb86 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/ProjectJETBundleProvider.java
@@ -110,6 +110,10 @@ public class ProjectJETBundleProvider implements IResourceChangeListener, IJETBu
public void shutdown()
{
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+
+ descriptorsById.clear();
+ projectNameToIdMap.clear();
}
/**
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeConditionalRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeConditionalRuntimeTag.java
index 30bb642..e4aca0d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeConditionalRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeConditionalRuntimeTag.java
@@ -64,7 +64,7 @@ public class SafeConditionalRuntimeTag extends SafeContainerRuntimeTag implement
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
ConditionalTag untrustedTag = (ConditionalTag)getUntrustedTag();
doEvalResult = untrustedTag.doEvalCondition(getTagInfo(), getContext());
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeContainerRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeContainerRuntimeTag.java
index e497873..1e2d9d4 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeContainerRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeContainerRuntimeTag.java
@@ -60,7 +60,7 @@ public class SafeContainerRuntimeTag extends SafeCustomRuntimeTag
// doAction()...
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
ContainerTag untrustedTag = (ContainerTag)getUntrustedTag();
untrustedTag.doAction(getTagInfo(), getContext(), getWriter());
@@ -80,7 +80,7 @@ public class SafeContainerRuntimeTag extends SafeCustomRuntimeTag
{
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
ContainerTag untrustedTag = (ContainerTag)getUntrustedTag();
untrustedTag.doBeforeBody(getTagInfo(), getContext(), getWriter());
@@ -99,7 +99,7 @@ public class SafeContainerRuntimeTag extends SafeCustomRuntimeTag
bodyProcessed = true;
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
ContainerTag untrustedTag = (ContainerTag)getUntrustedTag();
if (bodyContent != getWriter())
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeCustomRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeCustomRuntimeTag.java
index 9c7a0a7..8c6ea32 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeCustomRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeCustomRuntimeTag.java
@@ -26,6 +26,7 @@ import org.eclipse.jet.JET2Context;
import org.eclipse.jet.JET2Writer;
import org.eclipse.jet.internal.l10n.JET2Messages;
import org.eclipse.jet.taglib.CustomTag;
+import org.eclipse.jet.taglib.JET2TagException;
import org.eclipse.jet.taglib.RuntimeTagElement;
import org.eclipse.jet.taglib.TagInfo;
@@ -64,6 +65,19 @@ public abstract class SafeCustomRuntimeTag implements RuntimeTagElement
context.logError(tagInfo, null, exception);
}
}
+
+ public final void run() throws Exception
+ {
+ try {
+ doRun();
+ }
+ catch(JET2TagException e)
+ {
+ handleException(e);
+ }
+ }
+
+ protected abstract void doRun() throws Exception;
}
private RuntimeTagElement parentTag;
@@ -100,7 +114,7 @@ public abstract class SafeCustomRuntimeTag implements RuntimeTagElement
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
untrustedTag.setParent(customParent);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeEmptyRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeEmptyRuntimeTag.java
index 698e1d5..529c13a 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeEmptyRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeEmptyRuntimeTag.java
@@ -44,7 +44,7 @@ public class SafeEmptyRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
EmptyTag untrustedTag = (EmptyTag)getUntrustedTag();
untrustedTag.doAction(getTagInfo(), getContext(), getWriter());
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeFunctionRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeFunctionRuntimeTag.java
index c221f18..ebcb91b 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeFunctionRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeFunctionRuntimeTag.java
@@ -76,7 +76,7 @@ public class SafeFunctionRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
FunctionTag untrustedTag = (FunctionTag)getUntrustedTag();
functionResult = untrustedTag.doFunction(getTagInfo(), getContext(), bodyContent.toString());
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeIteratingRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeIteratingRuntimeTag.java
index bde3ae5..3e4ad83 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeIteratingRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeIteratingRuntimeTag.java
@@ -60,7 +60,7 @@ public class SafeIteratingRuntimeTag extends SafeContainerRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
IteratingTag untrustedTag = (IteratingTag)getUntrustedTag();
untrustedTag.doInitializeLoop(getTagInfo(), getContext());
@@ -85,7 +85,7 @@ public class SafeIteratingRuntimeTag extends SafeContainerRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
IteratingTag untrustedTag = (IteratingTag)getUntrustedTag();
okToProcessBodyResult = untrustedTag.doEvalLoopCondition(getTagInfo(), getContext());
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeOtherRuntimeTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeOtherRuntimeTag.java
index 8e4e577..8aaa04f 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeOtherRuntimeTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/runtime/SafeOtherRuntimeTag.java
@@ -47,7 +47,7 @@ public class SafeOtherRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
OtherTag untrustedTag = (OtherTag)getUntrustedTag();
untrustedTag.doStart(getTagInfo(), getContext(), getWriter());
@@ -63,7 +63,7 @@ public class SafeOtherRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
OtherTag untrustedTag = (OtherTag)getUntrustedTag();
untrustedTag.doEnd(getTagInfo(), getContext(), getWriter());
@@ -80,7 +80,7 @@ public class SafeOtherRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
OtherTag untrustedTag = (OtherTag)getUntrustedTag();
okToProcessBodyResult = untrustedTag.okToProcessBody(getTagInfo(), getContext());
@@ -97,7 +97,7 @@ public class SafeOtherRuntimeTag extends SafeCustomRuntimeTag
Platform.run(new TagSafeRunnable()
{
- public void run() throws Exception
+ public void doRun() throws Exception
{
OtherTag untrustedTag = (OtherTag)getUntrustedTag();
untrustedTag.handleBodyContent(getTagInfo(), getContext(), getWriter(), bodyContent);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/AbstractJavaFileTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/AbstractJavaFileTag.java
index 17966d9..066862d 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/AbstractJavaFileTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/java/AbstractJavaFileTag.java
@@ -93,8 +93,15 @@ public abstract class AbstractJavaFileTag extends AbstractEmptyTag
BodyContentWriter content = new BodyContentWriter();
final TransformContextExtender tce = TransformContextExtender.getInstance(context);
tce.execute(template, content);
- wce.addAction(new JavaFileAction(srcFolderPath, pkgName, fileName, content,
- replace, encoding, derived, td, tce.getTemplatePath()));
+ if(srcFolderPath != null && pkgName != null)
+ {
+ wce.addAction(new JavaFileAction(srcFolderPath, pkgName, fileName, content,
+ replace, encoding, derived, td, tce.getTemplatePath()));
+ }
+ else
+ {
+ throw new JET2TagException("Cannot write template result, as source folder or package could not be determined.");
+ }
}
protected abstract String getFileName() throws JET2TagException;
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/ProjectTag.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/ProjectTag.java
index da7d9ad..e705339 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/ProjectTag.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/internal/taglib/workspace/ProjectTag.java
@@ -57,7 +57,15 @@ public class ProjectTag extends AbstractContainerTag
WorkspaceContextExtender wsExtender = new WorkspaceContextExtender(context);
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ IProject project;
+ try
+ {
+ project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
+ }
+ catch (IllegalArgumentException e)
+ {
+ throw new JET2TagException(e.getMessage(), e);
+ }
TransformContextExtender tce = new TransformContextExtender(context);
wsExtender.addAction(new WsProjectAction(context, tce.getTemplatePath(), td, project));
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
index feb9c94..9ff5343 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/ActionsUtil.java
@@ -217,7 +217,7 @@ public final class ActionsUtil
}
catch (CoreException e)
{
- throw new JET2TagException(e);
+ throw new JET2TagException(e.getMessage(), e);
}
}
else
@@ -409,6 +409,11 @@ public final class ActionsUtil
monitor.worked(1);
}
}
+ catch(IllegalArgumentException e)
+ {
+ // create project throws this if the project name is invalid
+ throw new JET2TagException(e);
+ }
catch (CoreException e)
{
throw new JET2TagException(e);
diff --git a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
index b0050a3..682d635 100644
--- a/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
+++ b/plugins/org.eclipse.jet/src/org/eclipse/jet/taglib/workspace/WorkspaceContextExtender.java
@@ -186,9 +186,16 @@ public class WorkspaceContextExtender extends AbstractContextExtender
public void run() throws Exception
{
- if (action.requiresValidateEdit())
+ try
+ {
+ if (action.requiresValidateEdit())
+ {
+ filesToValidateEdit.add(action.getResource());
+ }
+ }
+ catch (JET2TagException e)
{
- filesToValidateEdit.add(action.getResource());
+ handleException(e);
}
}});
}
@@ -224,7 +231,14 @@ public class WorkspaceContextExtender extends AbstractContextExtender
public void run() throws Exception
{
- action.performAction(new SubProgressMonitor(submon, 1));
+ try
+ {
+ action.performAction(new SubProgressMonitor(submon, 1));
+ }
+ catch (JET2TagException e)
+ {
+ handleException(e);
+ }
}});
submon.worked(1);
}