Skip to content

Instantly share code, notes, and snippets.

private ClientConfiguration getClientConfigueration() {
Assert.notNull(proxy, "Proxy address not found!");
String host;
int port;
try {
URI uri = new URI(proxy);
host = uri.getHost();
port = uri.getPort();
} catch (URISyntaxException e) {
logger.error("Error creating client", e);
private ClientConfiguration getClientConfigueration() {
Assert.notNull(proxy, "Proxy address not found!");
return Try.of(() -> new URI(proxy))
.map(uri -> new ClientConfiguration()
.withProxyHost(uri.getHost())
.withProxyPort(uri.getPort())).getOrElseThrow(throwable ->
new S3StorageException("Unable to create client, proxy not available", throwable));
}
@sumew
sumew / observabletofuture.java
Created February 25, 2016 17:10
Convert an RX Observable to a Scala Promise
/**
* Converts an instance of <code>Observable<T></code> into
* an instance of <code>F.Promise<T></code>
*
* @return A <code>Promise<T></code> containing the value
* emitted by the observable
*/
public static <T> Function<Observable<T>, F.Promise<T>> observableToFuture()
{
return obs -> {
public enum CouchbaseCachingClient implements ICachingClient {
INSTANCE;
private final org.slf4j.Logger logger = Logger.init(CouchbaseCachingClient.class);
/**
* A default key used for constructing a JsonNode from a String
* when storing Strings into Couchbase.