List of usage examples for java.io IOException initCause
public synchronized Throwable initCause(Throwable cause)
From source file:org.apache.maven.plugin.assembly.format.ReaderFormatter.java
private static Reader createReaderFilter(@Nonnull Reader source, String escapeString, List<String> delimiters, AssemblerConfigurationSource configSource, boolean isPropertiesFile) throws IOException { try {/*from ww w. ja v a2 s .c o m*/ MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(source, true, configSource.getProject(), configSource.getFilters(), isPropertiesFile, null, configSource.getMavenSession(), null); // filterRequest.setInjectProjectBuildFilters(true); filterRequest.setEscapeString(escapeString); // if these are NOT set, just use the defaults, which are '${*}' and '@'. if (delimiters != null && !delimiters.isEmpty()) { LinkedHashSet<String> delims = new LinkedHashSet<String>(); for (String delim : delimiters) { if (delim == null) { // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution. delims.add("${*}"); } else { delims.add(delim); } } filterRequest.setDelimiters(delims); } else { filterRequest.setDelimiters(filterRequest.getDelimiters()); } filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters()); return configSource.getMavenReaderFilter().filter(filterRequest); } catch (MavenFilteringException e) { IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage()); ioe.initCause(e); // plain old Java 5... throw ioe; } }
From source file:org.apache.maven.plugins.assembly.format.ReaderFormatter.java
private static Reader createReaderFilter(@Nonnull Reader source, String escapeString, List<String> delimiters, AssemblerConfigurationSource configSource, boolean isPropertiesFile) throws IOException { try {/*from w w w . j a v a 2 s.c o m*/ MavenReaderFilterRequest filterRequest = new MavenReaderFilterRequest(source, true, configSource.getProject(), configSource.getFilters(), isPropertiesFile, configSource.getMavenSession(), null); filterRequest.setEscapeString(escapeString); // if these are NOT set, just use the defaults, which are '${*}' and '@'. if (delimiters != null && !delimiters.isEmpty()) { LinkedHashSet<String> delims = new LinkedHashSet<String>(); for (String delim : delimiters) { if (delim == null) { // FIXME: ${filter:*} could also trigger this condition. Need a better long-term solution. delims.add("${*}"); } else { delims.add(delim); } } filterRequest.setDelimiters(delims); } else { filterRequest.setDelimiters(filterRequest.getDelimiters()); } filterRequest.setInjectProjectBuildFilters(configSource.isIncludeProjectBuildFilters()); return configSource.getMavenReaderFilter().filter(filterRequest); } catch (MavenFilteringException e) { IOException ioe = new IOException("Error filtering file '" + source + "': " + e.getMessage()); ioe.initCause(e); // plain old Java 5... throw ioe; } }
From source file:org.apache.hadoop.hbase.snapshot.SnapshotManifestV1.java
static List<SnapshotRegionManifest> loadRegionManifests(final Configuration conf, final Executor executor, final FileSystem fs, final Path snapshotDir, final SnapshotDescription desc) throws IOException { FileStatus[] regions = FSUtils.listStatus(fs, snapshotDir, new FSUtils.RegionDirFilter(fs)); if (regions == null) { LOG.info("No regions under directory:" + snapshotDir); return null; }/* ww w . ja va 2s. c o m*/ final ExecutorCompletionService<SnapshotRegionManifest> completionService = new ExecutorCompletionService<SnapshotRegionManifest>( executor); for (final FileStatus region : regions) { completionService.submit(new Callable<SnapshotRegionManifest>() { @Override public SnapshotRegionManifest call() throws IOException { HRegionInfo hri = HRegionFileSystem.loadRegionInfoFileContent(fs, region.getPath()); return buildManifestFromDisk(conf, fs, snapshotDir, hri); } }); } ArrayList<SnapshotRegionManifest> regionsManifest = new ArrayList<SnapshotRegionManifest>(regions.length); try { for (int i = 0; i < regions.length; ++i) { regionsManifest.add(completionService.take().get()); } } catch (InterruptedException e) { throw new InterruptedIOException(e.getMessage()); } catch (ExecutionException e) { IOException ex = new IOException(); ex.initCause(e.getCause()); throw ex; } return regionsManifest; }
From source file:org.fusesource.meshkeeper.util.internal.FileSupport.java
public static void jar(File source, File target) throws IOException { ZipOutputStream os = new ZipOutputStream(new FileOutputStream(target)); try {/* w w w.ja va2 s . co m*/ os.setMethod(ZipOutputStream.DEFLATED); os.setLevel(5); recusiveJar(os, source, null); } catch (IOException ioe) { IOException nioe = new IOException("Error jarring " + source); nioe.initCause(ioe); throw nioe; } finally { close(os); } }
From source file:org.apache.nutch.indexwriter.elastic2.ElasticIndexWriter.java
public static IOException makeIOException(ElasticsearchException e) { final IOException ioe = new IOException(); ioe.initCause(e); return ioe;//from w w w . j a v a 2 s . co m }
From source file:com.alibaba.wasp.util.JVMClusterUtil.java
/** * Creates a {@link MasterThread}.//from ww w.j a v a 2 s . co m * Call 'start' on the returned thread to make it run. * @param c Configuration to use. * @param hmc Class to create. * @param index Used distinguishing the object returned. * @throws java.io.IOException * @return Master added. */ public static JVMClusterUtil.MasterThread createMasterThread(final Configuration c, final Class<? extends FMaster> hmc, final int index) throws IOException { FMaster server; try { server = hmc.getConstructor(Configuration.class).newInstance(c); } catch (InvocationTargetException ite) { Throwable target = ite.getTargetException(); throw new RuntimeException("Failed construction of Master: " + hmc.toString() + ((target.getCause() != null) ? target.getCause().getMessage() : ""), target); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } return new JVMClusterUtil.MasterThread(server, index); }
From source file:com.alibaba.wasp.util.JVMClusterUtil.java
/** * Creates a {@link FServerThread}.//from w w w . j ava 2s .c o m * Call 'start' on the returned thread to make it run. * @param c Configuration to use. * @param hrsc Class to create. * @param index Used distinguishing the object returned. * @throws java.io.IOException * @return FServer added. */ public static JVMClusterUtil.FServerThread createFServerThread(final Configuration c, final Class<? extends FServer> hrsc, final int index) throws IOException { FServer server; try { Constructor<? extends FServer> ctor = hrsc.getConstructor(Configuration.class); ctor.setAccessible(true); server = ctor.newInstance(c); } catch (InvocationTargetException ite) { Throwable target = ite.getTargetException(); throw new RuntimeException("Failed construction of FServer: " + hrsc.toString() + ((target.getCause() != null) ? target.getCause().getMessage() : ""), target); } catch (Exception e) { IOException ioe = new IOException(); ioe.initCause(e); throw ioe; } return new JVMClusterUtil.FServerThread(server, index); }
From source file:it.geosolutions.geofence.gui.server.utility.IoUtility.java
/** * Save compressed stream./*w ww. j av a2 s. c om*/ * * @param buffer * the buffer * @param out * the out * @param len * the len * @throws IOException * Signals that an I/O exception has occurred. */ public static void saveCompressedStream(final byte[] buffer, final OutputStream out, final int len) throws IOException { try { out.write(buffer, 0, len); } catch (Exception e) { out.flush(); out.close(); IOException ioe = new IOException("Not valid archive file type."); ioe.initCause(e); throw ioe; } }
From source file:org.fusesource.meshkeeper.util.internal.FileSupport.java
private static void recusiveJar(ZipOutputStream os, File source, String jarpath) throws IOException { String prefix = ""; if (jarpath != null) { ZipEntry entry = new ZipEntry(jarpath); entry.setTime(source.lastModified() + ROUNDUP_MILLIS); os.putNextEntry(entry);//w w w. j a va 2 s .co m prefix = jarpath + "/"; } if (source.isDirectory()) { for (File file : source.listFiles()) { recusiveJar(os, file, prefix + file.getName()); } } else { FileInputStream is = new FileInputStream(source); try { copy(is, os); } catch (IOException ioe) { IOException nioe = new IOException("Error jarring " + source); nioe.initCause(ioe); os.closeEntry(); LOG.warn("Skipping jar entry for " + source.getAbsolutePath() + " - " + nioe.getMessage()); if (LOG.isTraceEnabled()) { LOG.trace("Skipping jar entry for " + source.getAbsolutePath(), nioe); } } finally { close(is); } } }
From source file:org.dhatim.edisax.util.EdimapWriter.java
public static void write(Edimap edimap, Writer writer) throws IOException { try {/*from w w w . ja va 2 s. c om*/ EdimapWriter edimapWriter = new EdimapWriter(); edimapWriter.write(edimap); XmlUtil.serialize(edimapWriter.doc, true, writer); writer.flush(); } catch (ParserConfigurationException e) { IOException ioE = new IOException("Error constructing EDI Mapping Model"); ioE.initCause(e); throw ioE; } }