Skip to content
Snippets Groups Projects
Commit 665c5f62 authored by Nils Christian Ehmke's avatar Nils Christian Ehmke
Browse files

Code modifications for the quality tools.

parent 5ce75f53
No related branches found
No related tags found
No related merge requests found
...@@ -41,7 +41,7 @@ public final class ThemeSwitcherBean { ...@@ -41,7 +41,7 @@ public final class ThemeSwitcherBean {
/** /**
* A map containing all available themes. * 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. * Creates a new instance of this class.
......
...@@ -131,7 +131,7 @@ public class CurrentAnalysisControllerProjectBean { ...@@ -131,7 +131,7 @@ public class CurrentAnalysisControllerProjectBean {
public void instantiateAnalysis() { public void instantiateAnalysis() {
try { try {
ACManager.getInstance().instantiateAnalysisController(this.projectName); 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."); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis.");
} catch (final AnalysisConfigurationException e) { } catch (final AnalysisConfigurationException e) {
CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis."); CurrentAnalysisControllerProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An error occurred while instantiating the analysis.");
......
...@@ -66,7 +66,7 @@ public final class CurrentThemeBean { ...@@ -66,7 +66,7 @@ public final class CurrentThemeBean {
*/ */
public CurrentThemeBean() { public CurrentThemeBean() {
// Get the parameters within the current context. // 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. // Try to find the default theme within the parameters.
if (params.containsKey(CurrentThemeBean.KEY_THEME)) { if (params.containsKey(CurrentThemeBean.KEY_THEME)) {
this.theme = params.get(CurrentThemeBean.KEY_THEME); this.theme = params.get(CurrentThemeBean.KEY_THEME);
...@@ -76,7 +76,7 @@ public final class CurrentThemeBean { ...@@ -76,7 +76,7 @@ public final class CurrentThemeBean {
} }
// Try to find the cookie for the theme. // 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)) { if (cookies.containsKey(CurrentThemeBean.KEY_COOKIE_THEME)) {
this.theme = ((Cookie) cookies.get(CurrentThemeBean.KEY_COOKIE_THEME)).getValue(); this.theme = ((Cookie) cookies.get(CurrentThemeBean.KEY_COOKIE_THEME)).getValue();
...@@ -89,7 +89,9 @@ public final class CurrentThemeBean { ...@@ -89,7 +89,9 @@ public final class CurrentThemeBean {
* @return The currently used theme. * @return The currently used theme.
*/ */
public final String getTheme() { public final String getTheme() {
return this.theme; synchronized (this) {
return this.theme;
}
} }
/** /**
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
package kieker.webgui.beans.session; package kieker.webgui.beans.session;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -163,7 +164,9 @@ public final class CurrentWorkSpaceProjectBean { ...@@ -163,7 +164,9 @@ public final class CurrentWorkSpaceProjectBean {
* @return The project for this user. * @return The project for this user.
*/ */
public MIProject getProject() { public MIProject getProject() {
return this.project; synchronized (this) {
return this.project;
}
} }
/** /**
...@@ -524,8 +527,13 @@ public final class CurrentWorkSpaceProjectBean { ...@@ -524,8 +527,13 @@ public final class CurrentWorkSpaceProjectBean {
plugin.getRepositories().add(mConnector); plugin.getRepositories().add(mConnector);
} }
} catch (final Exception ex) { } catch (final InstantiationException e) {
// Inform the user about the fail! 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."); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the ports of the plugin.");
} }
} }
...@@ -548,8 +556,14 @@ public final class CurrentWorkSpaceProjectBean { ...@@ -548,8 +556,14 @@ public final class CurrentWorkSpaceProjectBean {
final Configuration configuration = repositoryInstance.getCurrentConfiguration(); final Configuration configuration = repositoryInstance.getCurrentConfiguration();
repository.getProperties().addAll(this.extractProperties(configuration)); 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."); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the repository.");
} }
} }
...@@ -571,8 +585,14 @@ public final class CurrentWorkSpaceProjectBean { ...@@ -571,8 +585,14 @@ public final class CurrentWorkSpaceProjectBean {
final Configuration configuration = pluginInstance.getCurrentConfiguration(); final Configuration configuration = pluginInstance.getCurrentConfiguration();
plugin.getProperties().addAll(this.extractProperties(configuration)); 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."); CurrentWorkSpaceProjectBean.showMessage(FacesMessage.SEVERITY_ERROR, "An errcor occured while loading the properties of the plugin.");
} }
} }
......
...@@ -170,7 +170,7 @@ public final class FSManager { ...@@ -170,7 +170,7 @@ public final class FSManager {
// Now the empty project file // Now the empty project file
try { try {
AnalysisController.saveToFile(projectFile, emptyProject); 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! // Something went wrong. Remove the directories and files!
final boolean viewDirDeleted = viewDir.delete(); final boolean viewDirDeleted = viewDir.delete();
final boolean libDirDeleted = libDir.delete(); final boolean libDirDeleted = libDir.delete();
...@@ -478,7 +478,7 @@ public final class FSManager { ...@@ -478,7 +478,7 @@ public final class FSManager {
BufferedInputStream in = null; BufferedInputStream in = null;
BufferedOutputStream out = null; BufferedOutputStream out = null;
IOException occException = null;
try { try {
// Get the streams. // Get the streams.
in = new BufferedInputStream(srcFile.getInputstream()); in = new BufferedInputStream(srcFile.getInputstream());
...@@ -494,13 +494,26 @@ public final class FSManager { ...@@ -494,13 +494,26 @@ public final class FSManager {
} }
} finally { } finally {
// Try to make sure that the streams will be closed. // Try to make sure that the streams will be closed.
if (in != null) { try {
in.close(); 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(); final MIDependency dependency = this.factory.createDependency();
......
...@@ -124,7 +124,7 @@ public final class PluginFinder { ...@@ -124,7 +124,7 @@ public final class PluginFinder {
// Try to find a class with the same name and put it into our list // Try to find a class with the same name and put it into our list
final Class<?> c = classLoader.loadClass(name); final Class<?> c = classLoader.loadClass(name);
result.add(c); result.add(c);
} catch (final Throwable ex) { // NOCS (IllegalCatchCheck) } catch (final Throwable ex) { // NOPMD (Generic throwable and empty catch block) NOCS (IllegalCatchCheck)
// Ignore error. // Ignore error.
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment