当前位置: 首页>>代码示例>>Java>>正文


Java IOException.getCause方法代码示例

本文整理汇总了Java中java.io.IOException.getCause方法的典型用法代码示例。如果您正苦于以下问题:Java IOException.getCause方法的具体用法?Java IOException.getCause怎么用?Java IOException.getCause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.io.IOException的用法示例。


在下文中一共展示了IOException.getCause方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleFailures

import java.io.IOException; //导入方法依赖的package包/类
private void handleFailures(IOException exception,
                                   FileStatus sourceFileStatus, Path target,
                                   Context context) throws IOException, InterruptedException {
  LOG.error("Failure in copying " + sourceFileStatus.getPath() + " to " +
              target, exception);

  if (ignoreFailures && exception.getCause() instanceof
          RetriableFileCopyCommand.CopyReadException) {
    incrementCounter(context, Counter.FAIL, 1);
    incrementCounter(context, Counter.BYTESFAILED, sourceFileStatus.getLen());
    context.write(null, new Text("FAIL: " + sourceFileStatus.getPath() + " - " +
        StringUtils.stringifyException(exception)));
  }
  else
    throw exception;
}
 
开发者ID:naver,项目名称:hadoop,代码行数:17,代码来源:CopyMapper.java

示例2: gcm_suppressUnreadCorrupt

import java.io.IOException; //导入方法依赖的package包/类
static void gcm_suppressUnreadCorrupt() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running supressUnreadCorrupt test");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail: " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:CipherInputStreamExceptions.java

示例3: cbc_shortRead600

import java.io.IOException; //导入方法依赖的package包/类
static void cbc_shortRead600() throws Exception {
    System.out.println("Running cbc_shortRead600");

    // Encrypt 600 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 600);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CipherInputStreamExceptions.java

示例4: testStandAloneClient

import java.io.IOException; //导入方法依赖的package包/类
@Test(timeout=60000)
public void testStandAloneClient() throws IOException {
  Client client = new Client(LongWritable.class, conf);
  InetSocketAddress address = new InetSocketAddress("127.0.0.1", 10);
  try {
    client.call(new LongWritable(RANDOM.nextLong()),
            address, null, null, 0, conf);
    fail("Expected an exception to have been thrown");
  } catch (IOException e) {
    String message = e.getMessage();
    String addressText = address.getHostName() + ":" + address.getPort();
    assertTrue("Did not find "+addressText+" in "+message,
            message.contains(addressText));
    Throwable cause=e.getCause();
    assertNotNull("No nested exception in "+e,cause);
    String causeText=cause.getMessage();
    assertTrue("Did not find " + causeText + " in " + message,
            message.contains(causeText));
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestIPC.java

示例5: moveToTrash

import java.io.IOException; //导入方法依赖的package包/类
private boolean moveToTrash(PathData item) throws IOException {
  boolean success = false;
  if (!skipTrash) {
    try {
      success = Trash.moveToAppropriateTrash(item.fs, item.path, getConf());
    } catch(FileNotFoundException fnfe) {
      throw fnfe;
    } catch (IOException ioe) {
      String msg = ioe.getMessage();
      if (ioe.getCause() != null) {
        msg += ": " + ioe.getCause().getMessage();
      }
      throw new IOException(msg + ". Consider using -skipTrash option", ioe);
    }
  }
  return success;
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:18,代码来源:Delete.java

示例6: cbc_shortRead400

import java.io.IOException; //导入方法依赖的package包/类
static void cbc_shortRead400() throws Exception {
    System.out.println("Running cbc_shortRead400");

    // Encrypt 400 byte with AES/CBC/PKCS5Padding
    byte[] ct = encryptedText("CBC", 400);
    // Create stream with encrypted data
    CipherInputStream in = getStream("CBC", ct);

    try {
        in.read();
        in.close();
        System.out.println("  Pass.");
    } catch (IOException e) {
        System.out.println("  Fail:  " + e.getMessage());
        throw new RuntimeException(e.getCause());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:CipherInputStreamExceptions.java

示例7: uploadThumbImage

import java.io.IOException; //导入方法依赖的package包/类
/**
 * 上传缩略图
 * 
 * @param client
 * @param inputStream
 * @param fileSize
 * @param fileExtName
 * @param metaDataSet
 */
private void uploadThumbImage(StorageNode client, InputStream inputStream, String masterFilename,
        String fileExtName) {
    ByteArrayInputStream thumbImageStream = null;
    try {
        thumbImageStream = getThumbImageStream(inputStream);// getFileInputStream
        // 获取文件大小
        long fileSize = thumbImageStream.available();
        // 获取缩略图前缀
        String prefixName = thumbImageConfig.getPrefixName();
        StorageUploadSlaveFileCommand command = new StorageUploadSlaveFileCommand(thumbImageStream, fileSize,
                masterFilename, prefixName, fileExtName);
        connectionManager.executeFdfsCmd(client.getInetSocketAddress(), command);

    } catch (IOException e) {
        LOGGER.error("upload ThumbImage error", e);
        throw new FdfsUploadImageException("upload ThumbImage error", e.getCause());
    } finally {
        IOUtils.closeQuietly(thumbImageStream);
    }
}
 
开发者ID:whatodo,项目名称:FastDFS_Client,代码行数:30,代码来源:DefaultFastFileStorageClient.java

示例8: handleFailures

import java.io.IOException; //导入方法依赖的package包/类
private void handleFailures(IOException exception, FileStatus sourceFileStatus, Path target, Context context)
  throws IOException, InterruptedException {
  LOG.error("Failure in copying {} to {}", sourceFileStatus.getPath(), target, exception);

  if (ignoreFailures && exception.getCause() instanceof RetriableFileCopyCommand.CopyReadException) {
    incrementCounter(context, Counter.FAIL, 1);
    incrementCounter(context, Counter.BYTESFAILED, sourceFileStatus.getLen());
    context.write(null,
        new Text("FAIL: " + sourceFileStatus.getPath() + " - " + StringUtils.stringifyException(exception)));
  } else {
    throw exception;
  }
}
 
开发者ID:HotelsDotCom,项目名称:circus-train,代码行数:14,代码来源:CopyMapper.java

示例9: testLogRollAfterSplitStart

import java.io.IOException; //导入方法依赖的package包/类
/**
 * Tests the case where a RegionServer enters a GC pause,
 * comes back online after the master declared it dead and started to split.
 * Want log rolling after a master split to fail. See HBASE-2312.
 */
@Test (timeout=300000)
public void testLogRollAfterSplitStart() throws IOException {
  LOG.info("Verify wal roll after split starts will fail.");
  String logName = "testLogRollAfterSplitStart";
  Path thisTestsDir = new Path(HBASEDIR, DefaultWALProvider.getWALDirectoryName(logName));
  final WALFactory wals = new WALFactory(conf, null, logName);

  try {
    // put some entries in an WAL
    TableName tableName =
        TableName.valueOf(this.getClass().getName());
    HRegionInfo regioninfo = new HRegionInfo(tableName,
        HConstants.EMPTY_START_ROW, HConstants.EMPTY_END_ROW);
    final WAL log = wals.getWAL(regioninfo.getEncodedNameAsBytes());
    MultiVersionConcurrencyControl mvcc = new MultiVersionConcurrencyControl(1);

    final int total = 20;
    for (int i = 0; i < total; i++) {
      WALEdit kvs = new WALEdit();
      kvs.add(new KeyValue(Bytes.toBytes(i), tableName.getName(), tableName.getName()));
      HTableDescriptor htd = new HTableDescriptor(tableName);
      htd.addFamily(new HColumnDescriptor("column"));
      log.append(htd, regioninfo, new WALKey(regioninfo.getEncodedNameAsBytes(), tableName,
          System.currentTimeMillis(), mvcc), kvs, true);
    }
    // Send the data to HDFS datanodes and close the HDFS writer
    log.sync();
    ((FSHLog) log).replaceWriter(((FSHLog)log).getOldPath(), null, null, null);

    /* code taken from MasterFileSystem.getLogDirs(), which is called from MasterFileSystem.splitLog()
     * handles RS shutdowns (as observed by the splitting process)
     */
    // rename the directory so a rogue RS doesn't create more WALs
    Path rsSplitDir = thisTestsDir.suffix(DefaultWALProvider.SPLITTING_EXT);
    if (!fs.rename(thisTestsDir, rsSplitDir)) {
      throw new IOException("Failed fs.rename for log split: " + thisTestsDir);
    }
    LOG.debug("Renamed region directory: " + rsSplitDir);

    LOG.debug("Processing the old log files.");
    WALSplitter.split(HBASEDIR, rsSplitDir, OLDLOGDIR, fs, conf, wals);

    LOG.debug("Trying to roll the WAL.");
    try {
      log.rollWriter();
      Assert.fail("rollWriter() did not throw any exception.");
    } catch (IOException ioe) {
      if (ioe.getCause() instanceof FileNotFoundException) {
        LOG.info("Got the expected exception: ", ioe.getCause());
      } else {
        Assert.fail("Unexpected exception: " + ioe);
      }
    }
  } finally {
    wals.close();
    if (fs.exists(thisTestsDir)) {
      fs.delete(thisTestsDir, true);
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:66,代码来源:TestLogRollAbort.java

示例10: start

import java.io.IOException; //导入方法依赖的package包/类
@EventListener(ContextStartedEvent.class)
public void start() throws Exception {
    int port = properties.getPort();
    NettyServerBuilder builder = NettyServerBuilder.forPort(port);
    bindableServices.forEach(builder::addService);
    if (properties.isSecure()) {
        configureSsl(builder);
    }
    grpcServer = builder.build();

    try {
        grpcServer.start();
    } catch (IOException e) {
        if (e.getCause() instanceof BindException) {
            throw new BindException("Address already in use: " + port);
        }
        throw new RuntimeException(e);
    }
    
    if (properties.getHealthCheckPort() > 0) {
        log.info("Starting health check at port {}", properties.getHealthCheckPort());
        healthCheckSocket = new ServerSocket(properties.getHealthCheckPort());
        healthChecker = new Thread(this::healthCheck, "Health Checker");
        healthChecker.setDaemon(true);
        healthChecker.start();
    }

    log.info("Server started, GRPC API listening on {}", grpcServer.getPort());

    String endpointUrl = properties.getEndpointUrl();
    if (endpointUrl == null) {
        log.warn("No endpoint url provided");
    } else {
        for (Address address : ethereumConfig.getAddresses()) {
            ContractsManager contractManager = factory.getContractManager(address);
            EndpointRegistry registry = new EndpointRegistry(contractManager.endpointRegistry());
            registry.registerEndpoint(address, endpointUrl);
        }
    }
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:41,代码来源:NodeServer.java

示例11: connectionFailed

import java.io.IOException; //导入方法依赖的package包/类
public boolean connectionFailed(IOException e) {
    this.isFallback = true;
    if (!this.isFallbackPossible || (e instanceof ProtocolException) || (e instanceof
            InterruptedIOException)) {
        return false;
    }
    if (((e instanceof SSLHandshakeException) && (e.getCause() instanceof
            CertificateException)) || (e instanceof SSLPeerUnverifiedException)) {
        return false;
    }
    if ((e instanceof SSLHandshakeException) || (e instanceof SSLProtocolException)) {
        return true;
    }
    return false;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:16,代码来源:ConnectionSpecSelector.java

示例12: isIOExceptionCausedByEPIPE

import java.io.IOException; //导入方法依赖的package包/类
private static boolean isIOExceptionCausedByEPIPE(IOException e) {
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
        return e.getMessage().contains("EPIPE");
    }

    Throwable cause = e.getCause();
    return cause instanceof ErrnoException && ((ErrnoException) cause).errno == OsConstants.EPIPE;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:9,代码来源:ParcelFileDescriptorUtil.java

示例13: testDeflate

import java.io.IOException; //导入方法依赖的package包/类
public static void testDeflate() {
		byte[] in = new byte[1500];
		for (int i=0;i<in.length;i++)in[i]=(byte)i;
//		new Random().nextBytes(in); // Random will actually make deflation bigger
		byte[] out = Utils.deflate(in, 0, in.length, 9);
		System.out.println("Before "+in.length+", after "+out.length);
		try {
			out = Utils.inflate(out, 0, out.length);
			System.out.println("Back "+out.length+", equals "+Arrays.equals(in, out));
		} catch (IOException e) {
			Throwable t = e.getCause();
			System.err.println(t.getClass()+" - "+t.getMessage());
		}
	}
 
开发者ID:matthieu-labas,项目名称:JRF,代码行数:15,代码来源:SmallTest.java

示例14: generateCodeEntry

import java.io.IOException; //导入方法依赖的package包/类
@Override
public void generateCodeEntry(YangPluginConfig yangPlugin)
        throws TranslatorException {
    try {
        updatePackageInfo(this, yangPlugin);
    } catch (IOException e) {
        throw new TranslatorException(e.getCause());
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:YangJavaGrouping.java

示例15: gcm_AEADBadTag

import java.io.IOException; //导入方法依赖的package包/类
static void gcm_AEADBadTag() throws Exception {
    Cipher c;
    byte[] read = new byte[200];

    System.out.println("Running gcm_AEADBadTag");

    // Encrypt 100 bytes with AES/GCM/PKCS5Padding
    byte[] ct = encryptedText("GCM", 100);
    // Corrupt the encrypted message
    ct = corruptGCM(ct);
    // Create stream for decryption
    CipherInputStream in = getStream("GCM", ct);

    try {
        int size = in.read(read);
        throw new RuntimeException("Fail: CipherInputStream.read() " +
                "returned " + size + " and didn't throw an exception.");
    } catch (IOException e) {
        Throwable ec = e.getCause();
        if (ec instanceof AEADBadTagException) {
            System.out.println("  Pass.");
        } else {
            System.out.println("  Fail: " + ec.getMessage());
            throw new RuntimeException(ec);
        }
    } finally {
        in.close();
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:CipherInputStreamExceptions.java


注:本文中的java.io.IOException.getCause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。