diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java index dbf06cc36bfc622b14517905676f5af938b5df62..e85f9764988d50fb2d2bae67453fac7f1bf679a2 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/application/ThemeSwitcherBean.java @@ -41,7 +41,7 @@ public final class ThemeSwitcherBean { /** * A map containing all available themes. */ - private final Map<String, String> themes = new TreeMap<String, String>(); + private final Map<String, String> themes = new TreeMap<String, String>(); // NOPMD (No concurrent access) /** * Creates a new instance of this class. diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java index 48ea2be77ec12a1e5ce58aee39aea91ee3edc310..67a3aaae27c7c5a17e0ab836758e3f2ab314571a 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentAnalysisControllerProjectBean.java @@ -131,7 +131,7 @@ public class CurrentAnalysisControllerProjectBean { public void instantiateAnalysis() { try { ACManager.getInstance().instantiateAnalysisController(this.projectName); - } catch (final NullPointerException e) { + } catch (final NullPointerException e) { // NOPMD (Exception is explicitly thrown) CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); } catch (final AnalysisConfigurationException e) { CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java index 99e7a72a4290d0cd1cf0aee4a985692c82c9925b..87dcf569404029ebfc1c845cb61365160d6e1bbe 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentThemeBean.java @@ -66,7 +66,7 @@ public final class CurrentThemeBean { */ public CurrentThemeBean() { // Get the parameters within the current context. - final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); + final Map<String, String> params = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap(); // NOPMD (No concurrent access) // Try to find the default theme within the parameters. if (params.containsKey(CurrentThemeBean.KEY_THEME)) { this.theme = params.get(CurrentThemeBean.KEY_THEME); @@ -76,7 +76,7 @@ public final class CurrentThemeBean { } // Try to find the cookie for the theme. - final Map<String, Object> cookies = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap(); + final Map<String, Object> cookies = FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap(); // NOPMD (No concurrent access) if (cookies.containsKey(CurrentThemeBean.KEY_COOKIE_THEME)) { this.theme = ((Cookie) cookies.get(CurrentThemeBean.KEY_COOKIE_THEME)).getValue(); @@ -89,7 +89,9 @@ public final class CurrentThemeBean { * @return The currently used theme. */ public final String getTheme() { - return this.theme; + synchronized (this) { + return this.theme; + } } /** diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java index 327b487de5c93e9399a7eb74bae3f0828153bea2..aea64a1a6dfe38f243fc9383a0cc66dfe2ad9001 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/beans/session/CurrentWorkSpaceProjectBean.java @@ -21,6 +21,7 @@ package kieker.webgui.beans.session; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Modifier; import java.net.MalformedURLException; import java.util.ArrayList; @@ -163,7 +164,9 @@ public final class CurrentWorkSpaceProjectBean { * @return The project for this user. */ public MIProject getProject() { - return this.project; + synchronized (this) { + return this.project; + } } /** @@ -524,8 +527,13 @@ public final class CurrentWorkSpaceProjectBean { plugin.getRepositories().add(mConnector); } - } catch (final Exception ex) { - // Inform the user about the fail! + } catch (final InstantiationException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); + } catch (final IllegalAccessException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); + } catch (final InvocationTargetException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); + } catch (final NoSuchMethodException e) { CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin."); } } @@ -548,8 +556,14 @@ public final class CurrentWorkSpaceProjectBean { final Configuration configuration = repositoryInstance.getCurrentConfiguration(); repository.getProperties().addAll(this.extractProperties(configuration)); - } catch (final Exception ex) { - // Inform the user about the fail! + + } catch (final InstantiationException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); + } catch (final IllegalAccessException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); + } catch (final InvocationTargetException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); + } catch (final NoSuchMethodException e) { CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository."); } } @@ -571,8 +585,14 @@ public final class CurrentWorkSpaceProjectBean { final Configuration configuration = pluginInstance.getCurrentConfiguration(); plugin.getProperties().addAll(this.extractProperties(configuration)); - } catch (final Exception ex) { - // Inform the user about the fail! + + } catch (final InstantiationException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); + } catch (final IllegalAccessException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); + } catch (final InvocationTargetException e) { + CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); + } catch (final NoSuchMethodException e) { CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin."); } } diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java index 541671aec999eb2b02f7cad23943a147c22a103d..248f2f72829c496c016147aa2fb221087ebfe056 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/FSManager.java @@ -170,7 +170,7 @@ public final class FSManager { // Now the empty project file try { AnalysisController.saveToFile(projectFile, emptyProject); - } catch (final IOException ex) { + } catch (final IOException ex) { // NOPMD (Rethrow to clean the directories) // Something went wrong. Remove the directories and files! final boolean viewDirDeleted = viewDir.delete(); final boolean libDirDeleted = libDir.delete(); @@ -478,7 +478,7 @@ public final class FSManager { BufferedInputStream in = null; BufferedOutputStream out = null; - + IOException occException = null; try { // Get the streams. in = new BufferedInputStream(srcFile.getInputstream()); @@ -494,13 +494,26 @@ public final class FSManager { } } finally { // Try to make sure that the streams will be closed. - if (in != null) { - in.close(); + try { + if (in != null) { + in.close(); + } + } catch (final IOException ex) { + occException = ex; } - if (out != null) { - out.close(); + + try { + if (out != null) { + out.close(); + } + } catch (final IOException ex) { + occException = ex; } } + // If something went wrong, rethrow the exception + if (occException != null) { + throw occException; + } } final MIDependency dependency = this.factory.createDependency(); diff --git a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java index 6e04c94f00105117503b55d14893d985cdd1eb94..a41c6e8367c37280f35d0a40c6b15f986ecdd820 100644 --- a/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java +++ b/Kieker.WebGUI/src/main/java/kieker/webgui/common/PluginFinder.java @@ -124,7 +124,7 @@ public final class PluginFinder { // Try to find a class with the same name and put it into our list final Class<?> c = classLoader.loadClass(name); result.add(c); - } catch (final Throwable ex) { // NOCS (IllegalCatchCheck) + } catch (final Throwable ex) { // NOPMD (Generic throwable and empty catch block) NOCS (IllegalCatchCheck) // Ignore error. } }