Fix various problems with resources potentially not being freed, and other minor fixes suggested by FindBugs

git-svn-id: http://scm.dspace.org/svn/repo/branches/dspace-1_5_x@3036 9c30dcfa-912a-0410-8fc2-9e0234be79fd
This commit is contained in:
Graham Triggs
2008-08-06 15:52:30 +00:00
parent 44cdd859a8
commit 9ae95a94e7
42 changed files with 1972 additions and 1190 deletions

View File

@@ -278,13 +278,19 @@ public class MetadataValue
valueId);
TableRow row = null;
if (tri.hasNext())
try
{
row = tri.next();
if (tri.hasNext())
{
row = tri.next();
}
}
finally
{
// close the TableRowIterator to free up resources
if (tri != null)
tri.close();
}
// close the TableRowIterator to free up resources
tri.close();
if (row == null)
{
@@ -316,14 +322,20 @@ public class MetadataValue
TableRow row = null;
java.util.Collection ret = new ArrayList();
while (tri.hasNext())
try
{
row = tri.next();
ret.add(new MetadataValue(row));
while (tri.hasNext())
{
row = tri.next();
ret.add(new MetadataValue(row));
}
}
finally
{
// close the TableRowIterator to free up resources
if (tri != null)
tri.close();
}
// close the TableRowIterator to free up resources
tri.close();
return ret;
}