mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-02-06 22:59:12 +01:00
fix potential bugs, detected by findbugs and pmd
This commit is contained in:
@@ -192,6 +192,20 @@ public class BasicContextProvider implements SCMContextProvider
|
||||
{
|
||||
throw new ConfigurationException(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
// do not use logger or IOUtil,
|
||||
// http://www.slf4j.org/codes.html#substituteLogger
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
ex.printStackTrace(System.err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties.getProperty(MAVEN_PROPERTY_VERSION, DEFAULT_VERSION);
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
@@ -104,6 +108,19 @@ public abstract class AbstractReader<T>
|
||||
*/
|
||||
public T read(File file) throws IOException
|
||||
{
|
||||
return read(new FileInputStream(file));
|
||||
T result = null;
|
||||
InputStream input = null;
|
||||
|
||||
try
|
||||
{
|
||||
input = new FileInputStream(file);
|
||||
result = read(input);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(input);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.io;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.BufferedReader;
|
||||
@@ -112,7 +116,20 @@ public abstract class AbstractResourceProcessor implements ResourceProcessor
|
||||
@Override
|
||||
public void process(File input, File output) throws IOException
|
||||
{
|
||||
process(new FileReader(input), new FileWriter(input));
|
||||
Reader reader = null;
|
||||
Writer writer = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader = new FileReader(input);
|
||||
writer = new FileWriter(output);
|
||||
process(reader, writer);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(reader);
|
||||
IOUtil.close(writer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,6 +106,25 @@ public class Changeset extends BasicPropertiesAware
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Changeset clone()
|
||||
{
|
||||
Changeset changeset = new Changeset(id, date, author, description);
|
||||
|
||||
changeset.setBranches(branches);
|
||||
changeset.setTags(tags);
|
||||
changeset.setModifications(modifications);
|
||||
changeset.setProperties(properties);
|
||||
|
||||
return changeset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
|
||||
@@ -49,7 +49,7 @@ public class FileObjectNameComparator implements Comparator<FileObject>
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
public static FileObjectNameComparator instance =
|
||||
public static final FileObjectNameComparator instance =
|
||||
new FileObjectNameComparator();
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
@@ -39,6 +39,8 @@ import sonia.scm.util.Util;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -54,9 +56,14 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
*/
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
@XmlRootElement(name = "modifications")
|
||||
public class Modifications
|
||||
public class Modifications implements Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -8902033326668658140L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs ...
|
||||
*
|
||||
|
||||
@@ -41,6 +41,8 @@ import sonia.scm.util.ValidationUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
@@ -52,9 +54,14 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
*/
|
||||
@XmlRootElement(name = "person")
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class Person implements Validateable
|
||||
public class Person implements Validateable, Serializable
|
||||
{
|
||||
|
||||
/** Field description */
|
||||
private static final long serialVersionUID = -4675080650527063196L;
|
||||
|
||||
//~--- constructors ---------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Person}.
|
||||
* This constructor is used by JAXB.
|
||||
@@ -90,7 +97,7 @@ public class Person implements Validateable
|
||||
|
||||
/**
|
||||
* Parses the given string and returns a {@link Person} object. The string
|
||||
* should be in the format "name >mail<". if the string contains no
|
||||
* should be in the format "name >mail<". if the string contains no
|
||||
* "><" the whole string is handled as the name of the {@link Person}.
|
||||
*
|
||||
*
|
||||
@@ -122,7 +129,7 @@ public class Person implements Validateable
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of the {@link Person} object,
|
||||
* Returns a string representation of the {@link Person} object,
|
||||
* in the format "name >mail<".
|
||||
*
|
||||
*
|
||||
|
||||
@@ -33,6 +33,10 @@
|
||||
|
||||
package sonia.scm.script;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.util.IOUtil;
|
||||
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.io.File;
|
||||
@@ -40,6 +44,7 @@ import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -70,7 +75,20 @@ public abstract class AbstractScmScriptContext implements ScmScriptContext
|
||||
"could not find script ".concat(file.getPath()));
|
||||
}
|
||||
|
||||
return createScript(new FileReader(file));
|
||||
ScmScript script = null;
|
||||
Reader reader = null;
|
||||
|
||||
try
|
||||
{
|
||||
reader = new FileReader(file);
|
||||
script = createScript(reader);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(reader);
|
||||
}
|
||||
|
||||
return script;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,6 +115,17 @@ public abstract class AbstractScmScriptContext implements ScmScriptContext
|
||||
"could not find script ".concat(path));
|
||||
}
|
||||
|
||||
return createScript(new InputStreamReader(stream));
|
||||
ScmScript script = null;
|
||||
|
||||
try
|
||||
{
|
||||
script = createScript(new InputStreamReader(stream));
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close(stream);
|
||||
}
|
||||
|
||||
return script;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ package sonia.scm.search;
|
||||
|
||||
//~--- non-JDK imports --------------------------------------------------------
|
||||
|
||||
import sonia.scm.Filter;
|
||||
import sonia.scm.TransformFilter;
|
||||
import sonia.scm.util.Util;
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ package sonia.scm.security;
|
||||
//~--- JDK imports ------------------------------------------------------------
|
||||
|
||||
import java.util.UUID;
|
||||
import sonia.scm.security.KeyGenerator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user