e2.initCause(e); throw e2;
/** * Potentially reads more bytes to fill the inflater's buffer and * reads from it. */ private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException { int read = 0; do { if (inf.needsInput()) { final int l = fill(); if (l > 0) { current.bytesReadFromStream += buf.limit(); } else if (l == -1) { return -1; } else { break; } } try { read = inf.inflate(buffer, offset, length); } catch (final DataFormatException e) { throw (IOException) new ZipException(e.getMessage()).initCause(e); } } while (read == 0 && inf.needsInput()); return read; }
/** * Constructs a ZIP parameters exception with * the given cause. * * @param cause the cause for this exception to get thrown. */ public ZipParametersException(@CheckForNull Throwable cause) { super(null != cause ? cause.toString() : null); super.initCause(cause); } }
/** * Constructs a ZIP crypto exception with * the given detail message and cause. * * @param msg the detail message. * @param cause the cause for this exception to be thrown. */ public ZipCryptoException(@CheckForNull String msg, @CheckForNull Throwable cause) { super(msg); super.initCause(cause); }
/** * Constructs a ZIP crypto exception with * the given cause. * * @param cause the cause for this exception to get thrown. */ public ZipCryptoException(@CheckForNull Throwable cause) { super(null != cause ? cause.toString() : null); super.initCause(cause); } }
@Override public int decompress(byte[] output) throws ZipException { try { return inflater.inflate(output); } catch (DataFormatException x) { throw (ZipException)new ZipException().initCause(x); } } }
/** * Returns a ZipFile. Same as calling * new ZipFile(file) * @param file the file to get a ZipFile for * @return a ZipFile * @throws IOException if an error occured */ public ZipFile getZipFile(final File file) throws IOException { try { if (System.getSecurityManager() == null) return new ZipFile(file); try { return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() { public ZipFile run() throws IOException { return new ZipFile(file); } }, controlContext); } catch (PrivilegedActionException e) { if (e.getException() instanceof IOException) throw (IOException) e.getException(); throw (RuntimeException) e.getException(); } } catch (ZipException e) { ZipException zipNameException = new ZipException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$ zipNameException.initCause(e); throw zipNameException; } catch (IOException e) { throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$ } }
/** * Returns a ZipFile. Same as calling * new ZipFile(file) * @param file the file to get a ZipFile for * @return a ZipFile * @throws IOException if an error occured */ public ZipFile getZipFile(final File file) throws IOException { try { if (System.getSecurityManager() == null) return new ZipFile(file); try { return AccessController.doPrivileged(new PrivilegedExceptionAction<ZipFile>() { public ZipFile run() throws IOException { return new ZipFile(file); } }, controlContext); } catch (PrivilegedActionException e) { if (e.getException() instanceof IOException) throw (IOException) e.getException(); throw (RuntimeException) e.getException(); } } catch (ZipException e) { ZipException zipNameException = new ZipException("Exception in opening zip file: " + file.getPath()); //$NON-NLS-1$ zipNameException.initCause(e); throw zipNameException; } catch (IOException e) { throw new IOException("Exception in opening zip file: " + file.getPath(), e); //$NON-NLS-1$ } }
zipNameException.initCause(e); throw zipNameException; } catch (IOException e) {
zipNameException.initCause(e); throw zipNameException; } catch (IOException e) {
zipNameException.initCause(e); throw zipNameException; } catch (IOException e) {
zipNameException.initCause(e); throw zipNameException; } catch (IOException e) {
zipNameException.initCause(e); throw zipNameException; } catch (IOException e) {
} catch (FileNotFoundException ex) { if (ex.getMessage().contains("Too many open files")) { throw (ZipException)new ZipException(ex.getMessage()).initCause(ex); } else { throw ex;
private Jar buildFromZip(File file) throws IOException { try { zipFile = new ZipFile(file); for (ZipEntry entry : Iterables.iterable(zipFile.entries())) { if (entry.isDirectory()) { continue; } putResource(entry.getName(), new ZipResource(zipFile, entry), true); } return this; } catch (ZipException e) { IO.close(zipFile); ZipException ze = new ZipException( "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage()); ze.initCause(e); throw ze; } catch (FileNotFoundException e) { IO.close(zipFile); throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath(), e); } catch (IOException e) { IO.close(zipFile); throw e; } }
private Jar buildFromZip(File file) throws IOException { try { zipFile = new ZipFile(file); for (ZipEntry entry : Iterables.iterable(zipFile.entries())) { if (entry.isDirectory()) { continue; } putResource(entry.getName(), new ZipResource(zipFile, entry), true); } return this; } catch (ZipException e) { IO.close(zipFile); ZipException ze = new ZipException( "The JAR/ZIP file (" + file.getAbsolutePath() + ") seems corrupted, error: " + e.getMessage()); ze.initCause(e); throw ze; } catch (FileNotFoundException e) { IO.close(zipFile); throw new IllegalArgumentException("Problem opening JAR: " + file.getAbsolutePath(), e); } catch (IOException e) { IO.close(zipFile); throw e; } }
/** * Potentially reads more bytes to fill the inflater's buffer and * reads from it. */ private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException { int read = 0; do { if (inf.needsInput()) { final int l = fill(); if (l > 0) { current.bytesReadFromStream += buf.limit(); } else if (l == -1) { return -1; } else { break; } } try { read = inf.inflate(buffer, offset, length); } catch (final DataFormatException e) { throw (IOException) new ZipException(e.getMessage()).initCause(e); } } while (read == 0 && inf.needsInput()); return read; }
/** * Potentially reads more bytes to fill the inflater's buffer and * reads from it. */ private int readFromInflater(final byte[] buffer, final int offset, final int length) throws IOException { int read = 0; do { if (inf.needsInput()) { final int l = fill(); if (l > 0) { current.bytesReadFromStream += buf.limit(); } else if (l == -1) { return -1; } else { break; } } try { read = inf.inflate(buffer, offset, length); } catch (final DataFormatException e) { throw (IOException) new ZipException(e.getMessage()).initCause(e); } } while (read == 0 && inf.needsInput()); return read; }
public Set<String> analyze( URL url ) throws IOException { CollectorClassFileVisitor visitor = new CollectorClassFileVisitor(); try { ClassFileVisitorUtils.accept( url, visitor ); } catch ( ZipException e ) { // since the current ZipException gives no indication what jar file is corrupted // we prefer to wrap another ZipException for better error visibility ZipException ze = new ZipException( "Cannot process Jar entry on URL: " + url + " due to " + e.getMessage() ); ze.initCause( e ); throw ze; } return visitor.getClasses(); } }