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:

DocumentImpl.java
1064 1064
			throws McdbException {
1065 1065
		String documentDir = null;
1066 1066
		String documentPath = null;
1067
		FileOutputStream fos = null;
1067 1068
		try {
1068 1069
			String separator = PropertyService.getProperty("document.accNumSeparator");
1069 1070
			documentDir = PropertyService.getProperty("application.documentfilepath");
......
1071 1072

  
1072 1073
			if (FileUtil.getFileStatus(documentPath) == FileUtil.DOES_NOT_EXIST
1073 1074
					|| FileUtil.getFileSize(documentPath) == 0) {
1074
				FileOutputStream fos = new FileOutputStream(documentPath);
1075
				fos = new FileOutputStream(documentPath);
1075 1076
				toXmlFromDb(fos, user, groups, true);
1077
				fos.close();
1078
				fos = null;
1076 1079
			}
1077 1080
		} catch (PropertyNotFoundException pnfe) {
1078 1081
			throw new McdbException("Could not write file: " + documentPath + " : "
......
1080 1083
		} catch (IOException ioe) {
1081 1084
			throw new McdbException("Could not write file: " + documentPath + " : "
1082 1085
					+ ioe.getMessage());
1083
		}
1086
        } finally {
1087
            if (fos != null) {
1088
                try {
1089
                    fos.close();
1090
                } catch (IOException ioe) {
1091
                    // Do nothing
1092
                }
1093
            }
1094
        }
1084 1095
		
1085 1096
		if (FileUtil.getFileSize(documentPath) == 0) {
1086 1097
			throw new McdbException("Attempting to read a zero length document from disk: " + documentPath);

Also available in: Unified diff