Project

General

Profile

« Previous | Next » 

Revision 8297

Added by Matt Jones over 10 years ago

Closing FileOutputStream handles so that the OS limits on filehandles are not exceeded.

View differences:

ReplicationService.java
1276 1276
		String urlString = null;
1277 1277
		String documentPath = null;
1278 1278
		String errorMsg = null;
1279
		FileOutputStream fos = null;
1279 1280
		try {
1280 1281
			// try to open a https stream to test if the request server's public
1281 1282
			// key
......
1307 1308
			// it to disk.
1308 1309
			if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST
1309 1310
					|| FileUtil.getFileSize(documentPath) == 0) {
1310
				FileOutputStream fos = new FileOutputStream(documentPath);
1311
				fos = new FileOutputStream(documentPath);
1311 1312
				di.toXml(fos, null, null, true);
1313
				fos.close();
1314
				fos = null;
1312 1315
			}
1313 1316

  
1314 1317
			// read the file from disk and send it to outputstream
......
1352 1355
							+ me.getMessage());
1353 1356
			// e.printStackTrace(System.out);
1354 1357
			errorMsg = me.getMessage();
1358
		} finally {
1359
            if (fos != null) {
1360
                try {
1361
                    fos.close();
1362
                } catch (IOException ioe) {
1363
                    // Do nothing
1364
                }
1365
            }
1355 1366
		}
1356 1367
		
1357 1368
		// report any errors if we got here

Also available in: Unified diff