501 return null; 502 } 503 504 InputStream inputStream = null; 505 try { 506 inputStream = errorStream == null 507 ? c.getInputStream() : errorStream; 508 } catch (HttpRetryException ex) { 509 // HttpRetryException is handled from doRun() method. 510 // Hence rethrowing the exception to caller(doRun() method) 511 throw ex; 512 } catch (IOException e) { 513 if (logger.isLoggable(Level.FINE)) { 514 logger.log(Level.FINE, String.format("Exception caught: [%s], %s", 515 e.getClass().getSimpleName(), 516 e.getMessage())); 517 } 518 } 519 520 String encoding = c.getContentEncoding(); 521 if ("gzip".equalsIgnoreCase(encoding)) { 522 inputStream = new GZIPInputStream(inputStream); 523 } else if ("deflate".equalsIgnoreCase(encoding)) { 524 inputStream = new InflaterInputStream(inputStream); 525 } 526 527 ByteBufferAllocator allocator = 528 byteBufferPool.newAllocator(MAX_BUF_COUNT); 529 ByteBuffer byteBuffer = null; 530 try { 531 if (inputStream != null) { 532 // 8192 is the default size of a BufferedInputStream used in 533 // most URLConnections, by using the same size, we avoid quite 534 // a few System.arrayCopy() calls 535 byte[] buffer = new byte[8192]; 536 while (!canceled) { 537 int count; 538 try { 539 count = inputStream.read(buffer); 540 } catch (EOFException ex) { 541 // can be thrown by GZIPInputStream signaling 542 // the end of the stream 543 count = -1; 544 } | 501 return null; 502 } 503 504 InputStream inputStream = null; 505 try { 506 inputStream = errorStream == null 507 ? c.getInputStream() : errorStream; 508 } catch (HttpRetryException ex) { 509 // HttpRetryException is handled from doRun() method. 510 // Hence rethrowing the exception to caller(doRun() method) 511 throw ex; 512 } catch (IOException e) { 513 if (logger.isLoggable(Level.FINE)) { 514 logger.log(Level.FINE, String.format("Exception caught: [%s], %s", 515 e.getClass().getSimpleName(), 516 e.getMessage())); 517 } 518 } 519 520 String encoding = c.getContentEncoding(); 521 if (inputStream != null) { 522 try { 523 if ("gzip".equalsIgnoreCase(encoding)) { 524 inputStream = new GZIPInputStream(inputStream); 525 } else if ("deflate".equalsIgnoreCase(encoding)) { 526 inputStream = new InflaterInputStream(inputStream); 527 } 528 } catch (IOException e) { 529 if (logger.isLoggable(Level.FINE)) { 530 logger.log(Level.FINE, String.format("Exception caught: [%s], %s", 531 e.getClass().getSimpleName(), 532 e.getMessage())); 533 } 534 } 535 } 536 537 ByteBufferAllocator allocator = 538 byteBufferPool.newAllocator(MAX_BUF_COUNT); 539 ByteBuffer byteBuffer = null; 540 try { 541 if (inputStream != null) { 542 // 8192 is the default size of a BufferedInputStream used in 543 // most URLConnections, by using the same size, we avoid quite 544 // a few System.arrayCopy() calls 545 byte[] buffer = new byte[8192]; 546 while (!canceled) { 547 int count; 548 try { 549 count = inputStream.read(buffer); 550 } catch (EOFException ex) { 551 // can be thrown by GZIPInputStream signaling 552 // the end of the stream 553 count = -1; 554 } |