fix some warning and removed some unused imports

This commit is contained in:
Sebastian Sdorra
2017-01-14 12:05:53 +01:00
parent c149b180a1
commit 7e6f4e1a7f
5 changed files with 26 additions and 59 deletions

View File

@@ -36,6 +36,7 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Closeables;
import com.google.common.io.Closer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,7 +127,6 @@ public class AbstractHgHandler
* @param handler
* @param context
* @param repository
* @param repositoryDirectory
*/
protected AbstractHgHandler(HgRepositoryHandler handler, HgContext context,
Repository repository)
@@ -166,7 +166,7 @@ public class AbstractHgHandler
*/
protected Map<String, String> createEnvironment(String revision, String path)
{
Map<String, String> env = new HashMap<String, String>();
Map<String, String> env = new HashMap<>();
env.put(ENV_REVISION, HgUtil.getRevision(revision));
env.put(ENV_PATH, Util.nonNull(path));
@@ -301,31 +301,16 @@ public class AbstractHgHandler
throws IOException, RepositoryException
{
Process p = createScriptProcess(script, extraEnv);
T result = null;
InputStream input = null;
OutputStream output = null;
try
{
handleErrorStream(p.getErrorStream());
input = p.getInputStream();
result =
(T) handler.getJaxbContext().createUnmarshaller().unmarshal(input);
input.close();
}
catch (JAXBException ex)
{
handleErrorStream(p.getErrorStream());
try (InputStream input = p.getInputStream()) {
return (T) handler.getJaxbContext().createUnmarshaller().unmarshal(input);
} catch (JAXBException ex) {
logger.error("could not parse result", ex);
throw new RepositoryException("could not parse result", ex);
}
finally
{
Closeables.closeQuietly(input);
Closeables.closeQuietly(output);
}
return result;
}
//~--- methods --------------------------------------------------------------

View File

@@ -34,7 +34,6 @@ package sonia.scm.repository;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Closeables;
import com.google.common.io.Resources;
import org.junit.Rule;
@@ -109,20 +108,13 @@ public class HgWindowsPackageFixTest
*/
private File createHgBat(String number) throws IOException
{
URL url =
Resources.getResource("sonia/scm/repository/hg.bat.".concat(number));
URL url = Resources.getResource("sonia/scm/repository/hg.bat.".concat(number));
File file = tempFolder.newFile(number);
FileOutputStream fos = null;
try
try (FileOutputStream fos = new FileOutputStream(file))
{
fos = new FileOutputStream(file);
Resources.copy(url, fos);
}
finally
{
Closeables.closeQuietly(fos);
}
return file;
}