Project

General

Profile

« Previous | Next » 

Revision 8301

Added by Matt Jones about 11 years ago

Closing some more streams that were left open. This Bug #6136 seems to be pervasive and is going to require an extensive audit to find all of the places where streams are not closed properly.

View differences:

src/edu/ucsb/nceas/metacat/replication/ReplicationService.java
1278 1278
		String documentPath = null;
1279 1279
		String errorMsg = null;
1280 1280
		FileOutputStream fos = null;
1281
		InputStream is = null;
1282
		OutputStream outputStream = null;
1281 1283
		try {
1282 1284
			// try to open a https stream to test if the request server's public
1283 1285
			// key
......
1310 1312
			if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST
1311 1313
					|| FileUtil.getFileSize(documentPath) == 0) {
1312 1314
				fos = new FileOutputStream(documentPath);
1313
				di.toXml(fos, null, null, true);
1315
				is = di.toXml(fos, null, null, true);
1314 1316
				fos.close();
1317
				is.close();
1315 1318
			}
1316 1319

  
1317 1320
			// read the file from disk and send it to outputstream
1318
			OutputStream outputStream = response.getOutputStream();
1319
			di.readFromFileSystem(outputStream, null, null, documentPath);
1321
			outputStream = response.getOutputStream();
1322
			is = di.readFromFileSystem(outputStream, null, null, documentPath);
1323
			is.close();
1324
			outputStream.close();
1320 1325

  
1321 1326
			logReplication.info("ReplicationService.handleGetDocumentRequest - document " + docid + " sent");
1322 1327

  
......
1357 1362
			errorMsg = me.getMessage();
1358 1363
		} finally {
1359 1364
            IOUtils.closeQuietly(fos);
1365
            IOUtils.closeQuietly(is);
1366
            IOUtils.closeQuietly(outputStream);
1360 1367
		}
1361 1368
		
1362 1369
		// report any errors if we got here

Also available in: Unified diff