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

@@ -581,27 +581,32 @@ public class Bitstream extends DSpaceObject
// Build a list of Bundle objects
List<Bundle> bundles = new ArrayList<Bundle>();
while (tri.hasNext())
try
{
TableRow r = tri.next();
// First check the cache
Bundle fromCache = (Bundle) bContext.fromCache(Bundle.class, r
.getIntColumn("bundle_id"));
if (fromCache != null)
while (tri.hasNext())
{
bundles.add(fromCache);
}
else
{
bundles.add(new Bundle(bContext, r));
TableRow r = tri.next();
// First check the cache
Bundle fromCache = (Bundle) bContext.fromCache(Bundle.class, r
.getIntColumn("bundle_id"));
if (fromCache != null)
{
bundles.add(fromCache);
}
else
{
bundles.add(new Bundle(bContext, r));
}
}
}
// close the TableRowIterator to free up resources
tri.close();
finally
{
// close the TableRowIterator to free up resources
if (tri != null)
tri.close();
}
Bundle[] bundleArray = new Bundle[bundles.size()];
bundleArray = (Bundle[]) bundles.toArray(bundleArray);