Changeset 7c7b0cb
- Timestamp:
- Apr 8, 2019 3:37:20 PM (22 months ago)
- Branches:
- master
- Children:
- 488e89a
- Parents:
- 6aeb89c
- Location:
- core/java/src/net/i2p/util
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
core/java/src/net/i2p/util/ResettableGZIPInputStream.java
r6aeb89c r7c7b0cb 167 167 return true; 168 168 } 169 } 170 171 /** 172 * Calls super.close(). May not be reused after this. 173 * @since 0.9.40 174 */ 175 public void destroy() throws IOException { 176 close(); 177 super.close(); 169 178 } 170 179 -
core/java/src/net/i2p/util/ResettableGZIPOutputStream.java
r6aeb89c r7c7b0cb 19 19 /** has the header been written out yet? */ 20 20 private boolean _headerWritten; 21 private boolean _footerWritten; 21 22 /** how much data is in the uncompressed stream? */ 22 23 private long _writtenSize; … … 40 41 _writtenSize = 0; 41 42 _headerWritten = false; 43 _footerWritten = false; 42 44 } 43 45 … … 62 64 63 65 private void writeFooter() throws IOException { 66 if (_footerWritten) return; 64 67 // damn RFC writing their bytes backwards... 65 68 long crcVal = _crc32.getValue(); … … 84 87 System.out.println(); 85 88 } 89 _footerWritten = true; 90 } 91 92 /** 93 * Calls super.close(). May not be reused after this. 94 * @since 0.9.40 95 */ 96 public void destroy() throws IOException { 97 def.end(); 98 super.close(); 86 99 } 87 100 … … 91 104 super.close(); 92 105 } 106 93 107 @Override 94 108 public void finish() throws IOException { … … 105 119 super.write(b); 106 120 } 121 107 122 @Override 108 123 public void write(byte buf[]) throws IOException { 109 124 write(buf, 0, buf.length); 110 125 } 126 111 127 @Override 112 128 public void write(byte buf[], int off, int len) throws IOException { -
core/java/src/net/i2p/util/ReusableGZIPInputStream.java
r6aeb89c r7c7b0cb 1 1 package net.i2p.util; 2 2 3 import java.io.IOException; 3 4 import java.util.concurrent.LinkedBlockingQueue; 4 5 … … 33 34 return rv; 34 35 } 36 35 37 /** 36 38 * Release an instance back into the cache (this will reset the … … 38 40 */ 39 41 public static void release(ReusableGZIPInputStream released) { 40 if (ENABLE_CACHING) 41 _available.offer(released); 42 boolean cached; 43 if (ENABLE_CACHING) { 44 cached = _available.offer(released); 45 } else { 46 cached = false; 47 } 48 if (!cached) { 49 try { released.destroy(); } catch (IOException ioe) {} 50 } 42 51 } 43 52 -
core/java/src/net/i2p/util/ReusableGZIPOutputStream.java
r6aeb89c r7c7b0cb 3 3 //import java.io.ByteArrayInputStream; 4 4 import java.io.ByteArrayOutputStream; 5 import java.io.IOException; 5 6 import java.util.zip.Deflater; 6 7 import java.util.concurrent.LinkedBlockingQueue; … … 51 52 */ 52 53 public static void release(ReusableGZIPOutputStream out) { 53 out.reset(); 54 if (ENABLE_CACHING) 55 _available.offer(out); 54 boolean cached; 55 if (ENABLE_CACHING) { 56 out.reset(); 57 cached = _available.offer(out); 58 } else { 59 cached = false; 60 } 61 if (!cached) { 62 try { out.destroy(); } catch (IOException ioe) {} 63 } 56 64 } 57 65
Note: See TracChangeset
for help on using the changeset viewer.