equal
deleted
inserted
replaced
410 throw new ZipException("invalid compression method"); |
410 throw new ZipException("invalid compression method"); |
411 } |
411 } |
412 } |
412 } |
413 } |
413 } |
414 |
414 |
|
415 private static class InflaterCleanupAction implements Runnable { |
|
416 private final Inflater inf; |
|
417 private final CleanableResource res; |
|
418 |
|
419 InflaterCleanupAction(Inflater inf, CleanableResource res) { |
|
420 this.inf = inf; |
|
421 this.res = res; |
|
422 } |
|
423 |
|
424 @Override |
|
425 public void run() { |
|
426 res.releaseInflater(inf); |
|
427 } |
|
428 } |
|
429 |
415 private class ZipFileInflaterInputStream extends InflaterInputStream { |
430 private class ZipFileInflaterInputStream extends InflaterInputStream { |
416 private volatile boolean closeRequested; |
431 private volatile boolean closeRequested; |
417 private boolean eof = false; |
432 private boolean eof = false; |
418 private final Cleanable cleanable; |
433 private final Cleanable cleanable; |
419 |
434 |
425 private ZipFileInflaterInputStream(ZipFileInputStream zfin, |
440 private ZipFileInflaterInputStream(ZipFileInputStream zfin, |
426 CleanableResource res, |
441 CleanableResource res, |
427 Inflater inf, int size) { |
442 Inflater inf, int size) { |
428 super(zfin, inf, size); |
443 super(zfin, inf, size); |
429 this.cleanable = CleanerFactory.cleaner().register(this, |
444 this.cleanable = CleanerFactory.cleaner().register(this, |
430 () -> res.releaseInflater(inf)); |
445 new InflaterCleanupAction(inf, res)); |
431 } |
446 } |
432 |
447 |
433 public void close() throws IOException { |
448 public void close() throws IOException { |
434 if (closeRequested) |
449 if (closeRequested) |
435 return; |
450 return; |
436 closeRequested = true; |
451 closeRequested = true; |