fix some deprecated warnings

This commit is contained in:
Sebastian Sdorra
2014-01-11 14:40:59 +01:00
parent 66da3a247b
commit a4e001808d
20 changed files with 119 additions and 113 deletions

View File

@@ -35,7 +35,7 @@ package sonia.scm.io;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Closeables;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -84,7 +84,7 @@ public abstract class AbstractWriter<T>
}
finally
{
Closeables.closeQuietly(output);
IOUtil.close(output);
}
}

View File

@@ -37,7 +37,6 @@ package sonia.scm.repository.api;
import com.google.common.base.Preconditions;
import com.google.common.base.Strings;
import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -46,6 +45,7 @@ import sonia.scm.repository.Repository;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.CatCommand;
import sonia.scm.repository.spi.CatCommandRequest;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -117,8 +117,8 @@ public final class CatCommandBuilder
* @throws RepositoryException
*/
public CatCommandBuilder retriveContent(OutputStream outputStream,
String path)
throws IOException, RepositoryException
String path)
throws IOException, RepositoryException
{
getCatResult(outputStream, path);
@@ -149,7 +149,7 @@ public final class CatCommandBuilder
}
finally
{
Closeables.closeQuietly(baos);
IOUtil.close(baos);
}
return content;
@@ -185,11 +185,11 @@ public final class CatCommandBuilder
* @throws RepositoryException
*/
private void getCatResult(OutputStream outputStream, String path)
throws IOException, RepositoryException
throws IOException, RepositoryException
{
Preconditions.checkNotNull(outputStream, "OutputStream is required");
Preconditions.checkArgument(!Strings.isNullOrEmpty(path),
"path is required");
"path is required");
CatCommandRequest requestClone = request.clone();
@@ -206,8 +206,8 @@ public final class CatCommandBuilder
//~--- fields ---------------------------------------------------------------
/** implementation of the cat command */
private CatCommand catCommand;
private final CatCommand catCommand;
/** request for the cat command */
private CatCommandRequest request = new CatCommandRequest();
private final CatCommandRequest request = new CatCommandRequest();
}

View File

@@ -36,7 +36,6 @@ package sonia.scm.repository.api;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -44,6 +43,7 @@ import org.slf4j.LoggerFactory;
import sonia.scm.repository.RepositoryException;
import sonia.scm.repository.spi.DiffCommand;
import sonia.scm.repository.spi.DiffCommandRequest;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
@@ -140,7 +140,7 @@ public final class DiffCommandBuilder
}
finally
{
Closeables.closeQuietly(baos);
IOUtil.close(baos);
}
return content;
@@ -149,15 +149,15 @@ public final class DiffCommandBuilder
//~--- set methods ----------------------------------------------------------
/**
* Sets the diff format which should be used for the output.
* <strong>Note: </strong> If the repository provider does not support the
* Sets the diff format which should be used for the output.
* <strong>Note: </strong> If the repository provider does not support the
* diff format, it will fallback to its default format.
*
*
* @param format format of the diff output
*
* @return {@code this}
*
*
* @since 1.34
*/
public DiffCommandBuilder setFormat(DiffFormat format)
@@ -228,8 +228,8 @@ public final class DiffCommandBuilder
//~--- fields ---------------------------------------------------------------
/** implementation of the diff command */
private DiffCommand diffCommand;
private final DiffCommand diffCommand;
/** request for the diff command implementation */
private DiffCommandRequest request = new DiffCommandRequest();
private final DiffCommandRequest request = new DiffCommandRequest();
}

View File

@@ -35,11 +35,11 @@ package sonia.scm.template;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.io.Closeables;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.IOUtil;
//~--- JDK imports ------------------------------------------------------------
import java.io.File;
@@ -124,7 +124,7 @@ public final class Templates
}
finally
{
Closeables.closeQuietly(reader);
IOUtil.close(reader);
}
}

View File

@@ -129,7 +129,7 @@ public final class IOUtil
}
catch (IOException ex)
{
logger.error(ex.getMessage(), ex);
logger.warn("IOException thrown while closing Closeable.", ex);
}
}
}

View File

@@ -36,12 +36,12 @@ package sonia.scm.web.filter;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Strings;
import com.google.common.io.Closeables;
import com.google.inject.Singleton;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import sonia.scm.util.IOUtil;
import sonia.scm.util.Util;
//~--- JDK imports ------------------------------------------------------------
@@ -87,8 +87,8 @@ public class LoggingFilter extends HttpFilter
*/
@Override
protected void doFilter(HttpServletRequest request,
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
HttpServletResponse response, FilterChain chain)
throws IOException, ServletException
{
if (logger.isDebugEnabled())
{
@@ -120,11 +120,11 @@ public class LoggingFilter extends HttpFilter
logger.debug("Info: Request-Uri = {}", request.getRequestURI());
logger.debug("Info: Remote-Addr = {}", request.getRemoteAddr());
logger.debug("Info: Remote-User = {}",
Util.nonNull(request.getRemoteUser()));
Util.nonNull(request.getRemoteUser()));
logger.debug("Info: Content-Size = {}",
Integer.toString(request.getContentLength()));
Integer.toString(request.getContentLength()));
logger.debug("Info: Content-Type = {}",
Util.nonNull(request.getContentType()));
Util.nonNull(request.getContentType()));
logger.debug("Info: Method = {}", request.getMethod());
logger.debug("Info: AuthType = {}", Util.nonNull(request.getAuthType()));
@@ -156,7 +156,7 @@ public class LoggingFilter extends HttpFilter
String parameter = (String) parameters.nextElement();
logger.debug("Parameter: {} = {}", parameter,
request.getParameter(parameter));
request.getParameter(parameter));
}
}
@@ -169,7 +169,7 @@ public class LoggingFilter extends HttpFilter
String attribute = (String) attributes.nextElement();
logger.debug("Attribute: {} = {}", attribute,
request.getAttribute(attribute).toString());
request.getAttribute(attribute).toString());
}
}
@@ -186,7 +186,7 @@ public class LoggingFilter extends HttpFilter
String sAttribute = (String) sAttributes.nextElement();
logger.debug("Session-Attribute: {} = {}", sAttribute,
request.getSession().getAttribute(sAttribute).toString());
request.getSession().getAttribute(sAttribute).toString());
}
}
@@ -212,18 +212,18 @@ public class LoggingFilter extends HttpFilter
* @throws IOException
*/
private void logResponse(HttpServletResponse orgResponse,
BufferedHttpServletResponse response)
throws IOException
BufferedHttpServletResponse response)
throws IOException
{
logger.debug("**************** response ****************");
logger.debug("status code = {}",
Integer.toString(response.getStatusCode()));
Integer.toString(response.getStatusCode()));
logger.debug("status message = {}",
Util.nonNull(response.getStatusMessage()));
Util.nonNull(response.getStatusMessage()));
logger.debug("charset = {}", Util.nonNull(response.getCharacterEncoding()));
logger.debug("content-type = {}", Util.nonNull(response.getContentType()));
logger.debug("content-length = {}",
Integer.toString(response.getContentLength()));
Integer.toString(response.getContentLength()));
for (Cookie cookie : response.getCookies())
{
@@ -250,7 +250,7 @@ public class LoggingFilter extends HttpFilter
}
finally
{
Closeables.closeQuietly(out);
IOUtil.close(out);
}
logger.trace("Content: ".concat(new String(content)));
@@ -297,6 +297,6 @@ public class LoggingFilter extends HttpFilter
private boolean isTextRequest(String contentType)
{
return !Strings.isNullOrEmpty(contentType)
&& contentType.toLowerCase(Locale.ENGLISH).startsWith("text");
&& contentType.toLowerCase(Locale.ENGLISH).startsWith("text");
}
}

View File

@@ -30,13 +30,14 @@
*/
package sonia.scm.web.proxy;
//~--- non-JDK imports --------------------------------------------------------
import com.google.common.base.Preconditions;
import com.google.common.io.ByteStreams;
import com.google.common.io.Closeables;
import com.google.common.io.Closer;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -48,6 +49,8 @@ import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
@@ -152,7 +155,7 @@ public class ProxyServlet extends HttpServlet
con.disconnect();
}
catch (Exception ex)
catch (IOException ex)
{
logger.error("could not proxy request", ex);
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
@@ -172,13 +175,14 @@ public class ProxyServlet extends HttpServlet
private void copyContent(HttpURLConnection con, HttpServletResponse response)
throws IOException
{
BufferedInputStream webToProxyBuf = null;
BufferedOutputStream proxyToClientBuf = null;
Closer closer = Closer.create();
try
{
webToProxyBuf = new BufferedInputStream(con.getInputStream());
proxyToClientBuf = new BufferedOutputStream(response.getOutputStream());
InputStream webToProxyBuf =
closer.register(new BufferedInputStream(con.getInputStream()));
OutputStream proxyToClientBuf =
closer.register(new BufferedOutputStream(response.getOutputStream()));
long bytes = ByteStreams.copy(webToProxyBuf, proxyToClientBuf);
@@ -186,8 +190,7 @@ public class ProxyServlet extends HttpServlet
}
finally
{
Closeables.closeQuietly(webToProxyBuf);
Closeables.closeQuietly(proxyToClientBuf);
closer.close();
}
}
@@ -307,5 +310,5 @@ public class ProxyServlet extends HttpServlet
//~--- fields ---------------------------------------------------------------
/** Field description */
private ProxyConfigurationProvider configurationProvider;
private final ProxyConfigurationProvider configurationProvider;
}