Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -114,27 +114,36 @@ List<String> generateOriginalItems(TransmissionHandlerArgs args) {

if (args.getTransmission().getWebContentEncodingType() == "gzip") {

GZIPInputStream gis = null;
BufferedReader bufferedReader = null;

try {
GZIPInputStream gis = new GZIPInputStream(
gis = new GZIPInputStream(
new ByteArrayInputStream(args.getTransmission().getContent()));
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gis));
bufferedReader = new BufferedReader(new InputStreamReader(gis));
String line;
while ((line = bufferedReader.readLine()) != null) {
originalItems.add(line);
}
} catch (IOException ex) {
InternalLogger.INSTANCE.error("IOException: Error while reading the GZIP stream.%nStack Trace:%n%s", ExceptionUtils.getStackTrace(ex));
} catch (Throwable t) {
InternalLogger.INSTANCE.error("Error while reading the GZIP stream.%nStack Trace:%n%s", ExceptionUtils.getStackTrace(t));
} finally {
if (gis != null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want, you can inline gis and remove this block. InputStreamReader and BufferedReader both close thier respective reader/stream in each of their close methods.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@littleaj yes I would like to see this change. Thanks for pointing out. It's not blocking but these are good performance constructs!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@littleaj - thanks, will follow up with you in person

gis.close();
try {
gis.close();
} catch (IOException ex){
InternalLogger.INSTANCE.warn("Error while closing the GZIP stream.%nStack Trace:%n%s", ExceptionUtils.getStackTrace(ex));
}
}
if (bufferedReader != null) {
bufferedReader.close();
try {
bufferedReader.close();
} catch (IOException ex){
InternalLogger.INSTANCE.warn("Error while closing the buffered reader.%nStack Trace:%n%s", ExceptionUtils.getStackTrace(ex));
}
}
} catch (IOException e1) {
InternalLogger.INSTANCE.error("IOException: Error while reading the GZIP stream.%nStack Trace:%n%s",
ExceptionUtils.getStackTrace(e1));
} catch (Throwable t) {
InternalLogger.INSTANCE.error("Error while reading the GZIP stream.%nStack Trace:%n%s",
ExceptionUtils.getStackTrace(t));
} finally {
}
} else {
for (String s : new String(args.getTransmission().getContent()).split("\r\n")) {
Expand Down