[FindBugs] Ensure resources are closed/freed properly

Removing dumb connector.close during server.getURI()
This commit is contained in:
Greg Wilkins 2014-07-17 10:00:26 +10:00
parent ec310dca90
commit 0c66f3a68e
5 changed files with 134 additions and 129 deletions

View File

@ -606,6 +606,7 @@ public class Server extends HandlerWrapper implements Attributes
/**
* @return The URI of the first {@link NetworkConnector} and first {@link ContextHandler}, or null
*/
@SuppressWarnings("resource")
public URI getURI()
{
NetworkConnector connector=null;

View File

@ -117,8 +117,8 @@ public class DefaultHandler extends AbstractHandler
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
response.setContentType(MimeTypes.Type.TEXT_HTML.toString());
ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500);
try (ByteArrayISO8859Writer writer = new ByteArrayISO8859Writer(1500);)
{
writer.write("<HTML>\n<HEAD>\n<TITLE>Error 404 - Not Found");
writer.write("</TITLE>\n<BODY>\n<H2>Error 404 - Not Found.</H2>\n");
writer.write("No context on this server matched or handled this request.<BR>");
@ -174,6 +174,7 @@ public class DefaultHandler extends AbstractHandler
writer.writeTo(out);
}
}
}
/* ------------------------------------------------------------ */
/**

View File

@ -133,6 +133,7 @@ public class ShutdownHandler extends HandlerWrapper
}
}
@SuppressWarnings("resource")
private String getServerUrl()
{
NetworkConnector connector=null;

View File

@ -666,13 +666,13 @@ public class HashSessionManager extends AbstractSessionManager
}
@SuppressWarnings("resource")
private void restoreSessionAttributes (InputStream is, int size, HashedSession session)
throws Exception
{
if (size>0)
{
// input stream should not be closed here
@SuppressWarnings("resource")
ClassLoadingObjectInputStream ois = new ClassLoadingObjectInputStream(is);
for (int i=0; i<size;i++)
{

View File

@ -684,8 +684,9 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
int c;
int totalLength = 0;
ByteArrayOutputStream2 output = new ByteArrayOutputStream2();
try(ByteArrayOutputStream2 output = new ByteArrayOutputStream2();)
{
int size=0;
while ((c=in.read())>0)
@ -767,6 +768,7 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
map.add(output.toString(charset),"");
}
}
}
/* -------------------------------------------------------------- */
/** Decode String with % encoding.