Tabnine Logo
IOException.getCause
Code IndexAdd Tabnine to your IDE (free)

How to use
getCause
method
in
java.io.IOException

Best Java code snippets using java.io.IOException.getCause (Showing top 20 results out of 4,356)

origin: square/okhttp

@Override public void onFailure(Call call, IOException e) {
 synchronized (lock) {
  this.callFailure = (e instanceof UnexpectedException) ? e.getCause() : e;
  lock.notifyAll();
 }
}
origin: square/okhttp

private boolean isRecoverable(IOException e, boolean requestSendStarted) {
 // If there was a protocol problem, don't recover.
 if (e instanceof ProtocolException) {
  return false;
 }
 // If there was an interruption don't recover, but if there was a timeout connecting to a route
 // we should try the next route (if there is one).
 if (e instanceof InterruptedIOException) {
  return e instanceof SocketTimeoutException && !requestSendStarted;
 }
 // Look for known client-side or negotiation errors that are unlikely to be fixed by trying
 // again with a different route.
 if (e instanceof SSLHandshakeException) {
  // If the problem was a CertificateException from the X509TrustManager,
  // do not retry.
  if (e.getCause() instanceof CertificateException) {
   return false;
  }
 }
 if (e instanceof SSLPeerUnverifiedException) {
  // e.g. a certificate pinning error.
  return false;
 }
 // An example of one we might want to retry with a different route is a problem connecting to a
 // proxy and would manifest as a standard IOException. Unless it is one we know we should not
 // retry, we return true and try a new route.
 return true;
}
origin: square/okhttp

if (e.getCause() instanceof CertificateException) {
 return false;
origin: prestodb/presto

@Override public void onFailure(Call call, IOException e) {
 synchronized (lock) {
  this.callFailure = (e instanceof UnexpectedException) ? e.getCause() : e;
  lock.notifyAll();
 }
}
origin: k9mail/k-9

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;
}
origin: signalapp/Signal-Server

 @Override
 public Response toResponse(IOException e) {
  if (!(e.getCause() instanceof java.util.concurrent.TimeoutException)) {
   logger.warn("IOExceptionMapper", e);
  }
  return Response.status(503).build();
 }
}
origin: alibaba/jstorm

  @Override
  public void run() {
    List<String> cmdWrapper = new ArrayList<>();
    cmdWrapper.add("nohup");
    cmdWrapper.addAll(cmdlist);
    cmdWrapper.add("&");
    try {
      launchProcess(cmdWrapper, environment);
    } catch (IOException e) {
      LOG.error("Failed to run nohup " + command + " &," + e.getCause(), e);
    }
  }
}).start();
origin: alibaba/jstorm

  @Override
  public void run() {
    List<String> cmdWrapper = new ArrayList<String>();
    cmdWrapper.add("nohup");
    cmdWrapper.addAll(cmdlist);
    cmdWrapper.add("&");
    try {
      launchProcess(cmdWrapper, environment);
    } catch (IOException e) {
      LOG.error("Failed to run nohup " + command + " &," + e.getCause(), e);
    }
  }
}).start();
origin: spotify/helios

@Override
public void shutDown() throws Exception {
 if (upNode != null) {
  try {
   upNode.close();
  } catch (IOException e) {
   final Throwable cause = fromNullable(e.getCause()).or(e);
   log.warn("Exception on closing up node: {}", cause);
  }
 }
}
origin: spotify/helios

@Override
public void shutDown() throws Exception {
 if (upNode != null) {
  try {
   upNode.close();
  } catch (IOException e) {
   final Throwable cause = fromNullable(e.getCause()).or(e);
   log.warn("Exception on closing up node: {}", cause);
  }
 }
}
origin: robovm/robovm

private boolean isEINPROGRESS(IOException e) {
  if (isBlocking()) {
    return false;
  }
  if (e instanceof ConnectException) {
    Throwable cause = e.getCause();
    if (cause instanceof ErrnoException) {
      return ((ErrnoException) cause).errno == EINPROGRESS;
    }
  }
  return false;
}
origin: confluentinc/ksql

 private static KsqlRequest deserialize(final String json) {
  try {
   return OBJECT_MAPPER.readValue(json, KsqlRequest.class);
  } catch (IOException e) {
   if (e.getCause() instanceof RuntimeException) {
    throw (RuntimeException) e.getCause();
   }
   throw new RuntimeException(e);
  }
 }
}
origin: checkstyle/checkstyle

  public void foo() {
    try (final InputStream foo = new ByteArrayInputStream(new byte[512])) {
      foo.read();
    }
    catch (final IOException e) {
      e.getCause();
    }
  }
}
origin: jenkinsci/jenkins

/**
 * Reverse operation of {@link #store(ConfidentialKey, byte[])}
 *
 * @return
 *      null the data has not been previously persisted.
 */
@Override
protected byte[] load(ConfidentialKey key) throws IOException {
  try {
    File f = getFileFor(key);
    if (!f.exists())    return null;
    Cipher sym = Secret.getCipher("AES");
    sym.init(Cipher.DECRYPT_MODE, masterKey);
    try (InputStream fis=Files.newInputStream(f.toPath());
       CipherInputStream cis = new CipherInputStream(fis, sym)) {
      byte[] bytes = IOUtils.toByteArray(cis);
      return verifyMagic(bytes);
    }
  } catch (GeneralSecurityException e) {
    throw new IOException("Failed to load the key: "+key.getId(),e);
  } catch (InvalidPathException e) {
    throw new IOException(e);
  } catch (IOException x) {
    if (x.getCause() instanceof BadPaddingException) {
      return null; // broken somehow
    } else {
      throw x;
    }
  }
}
origin: prestodb/presto

  @SuppressWarnings("unchecked")
  protected <T> T _handleDateTimeException(DeserializationContext ctxt,
       Class<?> type, DateTimeException e0, String value) throws IOException
  {
    try {
      return (T) ctxt.handleWeirdKey(type, value,
          "Failed to deserialize %s: (%s) %s",
          type.getName(), e0.getClass().getName(), e0.getMessage());

    } catch (JsonMappingException e) {
      e.initCause(e0);
      throw e;
    } catch (IOException e) {
      if (null == e.getCause()) {
        e.initCause(e0);
      }
      throw JsonMappingException.fromUnexpectedIOE(e);
    }
  }
}
origin: prestodb/presto

@SuppressWarnings("unchecked")
protected <R> R _handleDateTimeException(DeserializationContext context,
     DateTimeException e0, String value) throws JsonMappingException
{
  try {
    return (R) context.handleWeirdStringValue(handledType(), value,
        "Failed to deserialize %s: (%s) %s",
        handledType().getName(), e0.getClass().getName(), e0.getMessage());
  } catch (JsonMappingException e) {
    e.initCause(e0);
    throw e;
  } catch (IOException e) {
    if (null == e.getCause()) {
      e.initCause(e0);
    }
    throw JsonMappingException.fromUnexpectedIOE(e);
  }
}
origin: apache/hbase

private void handleEofException(IOException e) {
 if ((e instanceof EOFException || e.getCause() instanceof EOFException) &&
  logQueue.size() > 1 && this.eofAutoRecovery) {
  try {
   if (fs.getFileStatus(logQueue.peek()).getLen() == 0) {
    LOG.warn("Forcing removal of 0 length log in queue: " + logQueue.peek());
    logQueue.remove();
    currentPosition = 0;
   }
  } catch (IOException ioe) {
   LOG.warn("Couldn't get file length information about log " + logQueue.peek());
  }
 }
}
origin: apache/ignite

/**
 * @throws Exception If failed.
 */
@Test
public void testPutFieldsWithDefaultWriteObject() throws Exception {
  try {
    marshalUnmarshal(new CustomWriteObjectMethodObject("test"));
  }
  catch (IOException e) {
    assert e.getCause().getCause() instanceof NotActiveException;
  }
}
origin: apache/kafka

@Test
public void registerFailure() throws Exception {
  ChannelBuilder channelBuilder = new PlaintextChannelBuilder(null) {
    @Override
    public KafkaChannel buildChannel(String id, SelectionKey key, int maxReceiveSize,
        MemoryPool memoryPool) throws KafkaException {
      throw new RuntimeException("Test exception");
    }
    @Override
    public void close() {
    }
  };
  Selector selector = new Selector(5000, new Metrics(), new MockTime(), "MetricGroup", channelBuilder, new LogContext());
  SocketChannel socketChannel = SocketChannel.open();
  socketChannel.configureBlocking(false);
  try {
    selector.register("1", socketChannel);
    fail("Register did not fail");
  } catch (IOException e) {
    assertTrue("Unexpected exception: " + e, e.getCause().getMessage().contains("Test exception"));
    assertFalse("Socket not closed", socketChannel.isOpen());
  }
  selector.close();
}
origin: apache/hbase

 @Test
 public void testWrapException() throws Exception {
  final InetSocketAddress address = InetSocketAddress.createUnresolved("localhost", 0);
  assertTrue(wrapException(address, new ConnectException()) instanceof ConnectException);
  assertTrue(
   wrapException(address, new SocketTimeoutException()) instanceof SocketTimeoutException);
  assertTrue(wrapException(address, new ConnectionClosingException(
    "Test AbstractRpcClient#wrapException")) instanceof ConnectionClosingException);
  assertTrue(
   wrapException(address, new CallTimeoutException("Test AbstractRpcClient#wrapException"))
     .getCause() instanceof CallTimeoutException);
 }
}
java.ioIOExceptiongetCause

Popular methods of IOException

  • <init>
    Constructs a new instance of this class with its detail cause filled in.
  • getMessage
  • printStackTrace
  • toString
  • initCause
  • getLocalizedMessage
  • getStackTrace
  • addSuppressed
  • setStackTrace
  • fillInStackTrace
  • getSuppressed
  • getSuppressed

Popular in Java

  • Reading from database using SQL prepared statement
  • notifyDataSetChanged (ArrayAdapter)
  • getSharedPreferences (Context)
  • getResourceAsStream (ClassLoader)
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • SimpleDateFormat (java.text)
    Formats and parses dates in a locale-sensitive manner. Formatting turns a Date into a String, and pa
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • IsNull (org.hamcrest.core)
    Is the value null?
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now