3636import microsoft .exchange .webservices .data .core .exception .xml .XmlException ;
3737import microsoft .exchange .webservices .data .misc .HangingTraceStream ;
3838import microsoft .exchange .webservices .data .security .XmlNodeType ;
39+ import org .apache .commons .io .IOUtils ;
3940import org .apache .commons .logging .Log ;
4041import org .apache .commons .logging .LogFactory ;
4142
@@ -241,14 +242,7 @@ private void parseResponses() {
241242 // Stream is closed, so disconnect.
242243 this .disconnect (HangingRequestDisconnectReason .Exception , ex );
243244 } finally {
244- if (responseCopy != null ) {
245- try {
246- responseCopy .close ();
247- responseCopy = null ;
248- } catch (Exception ex ) {
249- LOG .error (ex );
250- }
251- }
245+ IOUtils .closeQuietly (responseCopy );
252246 }
253247 }
254248
@@ -272,11 +266,7 @@ private void setIsConnected(boolean value) {
272266 */
273267 public void disconnect () {
274268 synchronized (this ) {
275- try {
276- this .response .close ();
277- } catch (IOException e ) {
278- // Ignore exception on disconnection
279- }
269+ IOUtils .closeQuietly (this .response );
280270 this .disconnect (HangingRequestDisconnectReason .UserInitiated , null );
281271 }
282272 }
@@ -289,11 +279,7 @@ public void disconnect() {
289279 */
290280 public void disconnect (HangingRequestDisconnectReason reason , Exception exception ) {
291281 if (this .isConnected ()) {
292- try {
293- this .response .close ();
294- } catch (IOException e ) {
295- // Ignore exception on disconnection
296- }
282+ IOUtils .closeQuietly (this .response );
297283 this .internalOnDisconnect (reason , exception );
298284 }
299285 }
0 commit comments