Skip to content

Commit cfd3d42

Browse files
committed
Caldav: cleanup from audit
git-svn-id: https://svn.code.sf.net/p/davmail/code/trunk@4109 3d1905a2-6b24-0410-a738-b14d5a86fcbd
1 parent 233565f commit cfd3d42

1 file changed

Lines changed: 22 additions & 21 deletions

File tree

src/java/davmail/caldav/CaldavConnection.java

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,27 +1104,28 @@ public void sendFreeBusy(String body) throws IOException {
11041104
HashMap<String, String> valueMap = new HashMap<>();
11051105
ArrayList<String> attendees = new ArrayList<>();
11061106
HashMap<String, String> attendeeKeyMap = new HashMap<>();
1107-
ICSBufferedReader reader = new ICSBufferedReader(new StringReader(body));
1108-
String line;
1109-
String key;
1110-
while ((line = reader.readLine()) != null) {
1111-
int index = line.indexOf(':');
1112-
if (index <= 0) {
1113-
throw new DavMailException("EXCEPTION_INVALID_REQUEST", body);
1114-
}
1115-
String fullkey = line.substring(0, index);
1116-
String value = line.substring(index + 1);
1117-
int semicolonIndex = fullkey.indexOf(';');
1118-
if (semicolonIndex > 0) {
1119-
key = fullkey.substring(0, semicolonIndex);
1120-
} else {
1121-
key = fullkey;
1122-
}
1123-
if ("ATTENDEE".equals(key)) {
1124-
attendees.add(value);
1125-
attendeeKeyMap.put(value, fullkey);
1126-
} else {
1127-
valueMap.put(key, value);
1107+
try (ICSBufferedReader reader = new ICSBufferedReader(new StringReader(body))) {
1108+
String line;
1109+
String key;
1110+
while ((line = reader.readLine()) != null) {
1111+
int index = line.indexOf(':');
1112+
if (index <= 0) {
1113+
throw new DavMailException("EXCEPTION_INVALID_REQUEST", body);
1114+
}
1115+
String fullkey = line.substring(0, index);
1116+
String value = line.substring(index + 1);
1117+
int semicolonIndex = fullkey.indexOf(';');
1118+
if (semicolonIndex > 0) {
1119+
key = fullkey.substring(0, semicolonIndex);
1120+
} else {
1121+
key = fullkey;
1122+
}
1123+
if ("ATTENDEE".equals(key)) {
1124+
attendees.add(value);
1125+
attendeeKeyMap.put(value, fullkey);
1126+
} else {
1127+
valueMap.put(key, value);
1128+
}
11281129
}
11291130
}
11301131
// get freebusy for each attendee

0 commit comments

Comments
 (0)