Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit b7f306f

Browse files
authored
Merge pull request #573 from standlove/dev
fix crash
2 parents 5331dbe + 2c9351c commit b7f306f

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/java/main/com/topcoder/direct/services/view/ajax/CustomFormatAJAXResult.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.io.IOException;
99
import java.io.InputStream;
1010
import java.io.OutputStream;
11+
import java.net.SocketException;
1112
import java.nio.charset.Charset;
1213
import java.nio.charset.IllegalCharsetNameException;
1314
import java.util.zip.GZIPOutputStream;
@@ -81,14 +82,21 @@
8182
* </p>
8283
*
8384
* <p>
85+
* Version 1.2
86+
* <ul>
87+
* <li>Fixed crash - java.net.SocketException: Broken pipe</li>
88+
* </ul>
89+
* </p>
90+
*
91+
* <p>
8492
* Thread safety: Technically this class is NOT thread safe since it has mutable states, but the intended
8593
* usage of the mutators is for IoC injection and thus we expect for these values not to be changed after
8694
* initialization. Thus this class can be considered as thread-safe conditional in an IoC injection usage of
8795
* the mutators.
8896
* </p>
8997
*
9098
* @author AleaActaEst, TCSDEVELOPER, duxiaoyang
91-
* @version 1.1
99+
* @version 1.2
92100
*/
93101
@SuppressWarnings("serial")
94102
public class CustomFormatAJAXResult implements Result {
@@ -300,11 +308,13 @@ private static void writeDataAndClose(InputStream in, OutputStream out) throws I
300308
}
301309
// flush output stream
302310
out.flush();
311+
} catch (SocketException e) {
312+
// The client side has aborted or closed connection
303313
} finally {
304314
// close the input stream
305315
closeStream(in);
306316
// close the output stream
307-
out.close();
317+
closeStream(out);
308318
}
309319
}
310320

0 commit comments

Comments
 (0)