410 throw new ZipException("invalid compression method");
411 }
412 }
413 }
414
415 private class ZipFileInflaterInputStream extends InflaterInputStream {
416 private volatile boolean closeRequested;
417 private boolean eof = false;
418 private final Cleanable cleanable;
419
420 ZipFileInflaterInputStream(ZipFileInputStream zfin,
421 CleanableResource res, int size) {
422 this(zfin, res, res.getInflater(), size);
423 }
424
425 private ZipFileInflaterInputStream(ZipFileInputStream zfin,
426 CleanableResource res,
427 Inflater inf, int size) {
428 super(zfin, inf, size);
429 this.cleanable = CleanerFactory.cleaner().register(this,
430 new Runnable() {
431 @Override
432 public void run() {
433 res.releaseInflater(inf);
434 }
435 });
436 }
437
438 public void close() throws IOException {
439 if (closeRequested)
440 return;
441 closeRequested = true;
442 super.close();
443 synchronized (res.istreams) {
444 res.istreams.remove(this);
445 }
446 cleanable.clean();
447 }
448
449 // Override fill() method to provide an extra "dummy" byte
450 // at the end of the input stream. This is required when
451 // using the "nowrap" Inflater option.
452 protected void fill() throws IOException {
453 if (eof) {
454 throw new EOFException("Unexpected end of ZLIB input stream");
455 }
|
410 throw new ZipException("invalid compression method");
411 }
412 }
413 }
414
415 private class ZipFileInflaterInputStream extends InflaterInputStream {
416 private volatile boolean closeRequested;
417 private boolean eof = false;
418 private final Cleanable cleanable;
419
420 ZipFileInflaterInputStream(ZipFileInputStream zfin,
421 CleanableResource res, int size) {
422 this(zfin, res, res.getInflater(), size);
423 }
424
425 private ZipFileInflaterInputStream(ZipFileInputStream zfin,
426 CleanableResource res,
427 Inflater inf, int size) {
428 super(zfin, inf, size);
429 this.cleanable = CleanerFactory.cleaner().register(this,
430 () -> res.releaseInflater(inf));
431 }
432
433 public void close() throws IOException {
434 if (closeRequested)
435 return;
436 closeRequested = true;
437 super.close();
438 synchronized (res.istreams) {
439 res.istreams.remove(this);
440 }
441 cleanable.clean();
442 }
443
444 // Override fill() method to provide an extra "dummy" byte
445 // at the end of the input stream. This is required when
446 // using the "nowrap" Inflater option.
447 protected void fill() throws IOException {
448 if (eof) {
449 throw new EOFException("Unexpected end of ZLIB input stream");
450 }
|