Java Code Examples for com.google.api.client.util.Throwables#propagateIfPossible()

The following examples show how to use com.google.api.client.util.Throwables#propagateIfPossible() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CustomLocalServerReceiver.java    From hop with Apache License 2.0 6 votes vote down vote up
public String getRedirectUri() throws IOException {
  if ( this.port == -1 ) {
    this.port = getUnusedPort();
  }

  this.server = new Server( this.port );
  Connector[] arr$ = this.server.getConnectors();
  int len$ = arr$.length;

  for ( int i$ = 0; i$ < len$; ++i$ ) {
    Connector c = arr$[i$];
    c.setHost( this.host );
  }

  this.server.addHandler( new CustomLocalServerReceiver.CallbackHandler() );

  try {
    this.server.start();
  } catch ( Exception var5 ) {
    Throwables.propagateIfPossible( var5 );
    throw new IOException( var5 );
  }

  return "http://" + this.host + ":" + this.port + "/Callback/success.html";
}
 
Example 2
Source File: LocalServerReceiver.java    From google-oauth-java-client with Apache License 2.0 6 votes vote down vote up
@Override
public String getRedirectUri() throws IOException {

  server = HttpServer.create(new InetSocketAddress(port != -1 ? port : findOpenPort()), 0);
  HttpContext context = server.createContext(callbackPath, new CallbackHandler());
  server.setExecutor(null);

  try {
    server.start();
    port = server.getAddress().getPort();
  } catch (Exception e) {
    Throwables.propagateIfPossible(e);
    throw new IOException(e);
  }
  return "http://" + this.getHost() + ":" + port + callbackPath;
}
 
Example 3
Source File: CustomLocalServerReceiver.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public String getRedirectUri() throws IOException {
  if ( this.port == -1 ) {
    this.port = getUnusedPort();
  }

  this.server = new Server( this.port );
  Connector[] arr$ = this.server.getConnectors();
  int len$ = arr$.length;

  for ( int i$ = 0; i$ < len$; ++i$ ) {
    Connector c = arr$[i$];
    c.setHost( this.host );
  }

  this.server.addHandler( new CustomLocalServerReceiver.CallbackHandler() );

  try {
    this.server.start();
  } catch ( Exception var5 ) {
    Throwables.propagateIfPossible( var5 );
    throw new IOException( var5 );
  }

  return "http://" + this.host + ":" + this.port + "/Callback/success.html";
}
 
Example 4
Source File: CustomLocalServerReceiver.java    From hop with Apache License 2.0 5 votes vote down vote up
public void stop() throws IOException {
  if ( this.server != null ) {
    try {
      this.server.stop();
    } catch ( Exception var2 ) {
      Throwables.propagateIfPossible( var2 );
      throw new IOException( var2 );
    }
    this.server = null;
  }
}
 
Example 5
Source File: ProtocolBuffers.java    From google-http-java-client with Apache License 2.0 5 votes vote down vote up
/**
 * Parses protocol buffer content from an input stream (closing the input stream) into a protocol
 * buffer message.
 *
 * @param <T> destination message type
 * @param messageClass destination message class that has a {@code parseFrom(InputStream)} public
 *     static method
 * @return new instance of the parsed destination message class
 */
public static <T extends MessageLite> T parseAndClose(
    InputStream inputStream, Class<T> messageClass) throws IOException {
  try {
    Method newBuilder = messageClass.getDeclaredMethod("parseFrom", InputStream.class);
    return messageClass.cast(newBuilder.invoke(null, inputStream));
  } catch (Exception e) {
    Throwables.propagateIfPossible(e, IOException.class);
    IOException io = new IOException("Error parsing message of type " + messageClass);
    io.initCause(e);
    throw io;
  } finally {
    inputStream.close();
  }
}
 
Example 6
Source File: LocalServerReceiver.java    From google-oauth-java-client with Apache License 2.0 5 votes vote down vote up
@Override
public void stop() throws IOException {
  waitUnlessSignaled.release();
  if (server != null) {
    try {
      server.stop(0);
    } catch (Exception e) {
      Throwables.propagateIfPossible(e);
      throw new IOException(e);
    }
    server = null;
  }
}
 
Example 7
Source File: CustomLocalServerReceiver.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
public void stop() throws IOException {
  if ( this.server != null ) {
    try {
      this.server.stop();
    } catch ( Exception var2 ) {
      Throwables.propagateIfPossible( var2 );
      throw new IOException( var2 );
    }
    this.server = null;
  }
}