Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing deprecated RxJava usage #305

Merged
merged 1 commit into from
Sep 3, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void testGetUserByIdObservable() {
try {

// blocking
assertEquals("name: 1", userService.getUser("1", "name: ").toBlockingObservable().single().getName());
assertEquals("name: 1", userService.getUser("1", "name: ").toBlocking().single().getName());

// non-blocking
// - this is a verbose anonymous inner-class approach and doesn't do assertions
Expand Down Expand Up @@ -88,7 +88,7 @@ public void testGetUserWithFallback() {
final User exUser = new User("def", "def");

// blocking
assertEquals(exUser, userService.getUser(" ", "").toBlockingObservable().single());
assertEquals(exUser, userService.getUser(" ", "").toBlocking().single());
assertEquals(1, HystrixRequestLog.getCurrentRequest().getExecutedCommands().size());
com.netflix.hystrix.HystrixCommand getUserCommand = getHystrixCommandByKey("getUser");
// confirm that command has failed
Expand Down
2 changes: 1 addition & 1 deletion hystrix-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ apply plugin: 'idea'

dependencies {
compile 'com.netflix.archaius:archaius-core:0.4.1'
compile 'com.netflix.rxjava:rxjava-core:0.20.1'
compile 'com.netflix.rxjava:rxjava-core:0.20.3'
compile 'org.slf4j:slf4j-api:1.7.0'
compile 'com.google.code.findbugs:jsr305:2.0.0'
provided 'junit:junit-dep:4.10'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ public ResponseType execute() {
*/
public Future<ResponseType> queue() {
final Observable<ResponseType> o = toObservable();
return o.toBlockingObservable().toFuture();
return o.toBlocking().toFuture();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public Future<R> queue() {
* is going to sit waiting on it.
*/
final ObservableCommand<R> o = toObservable(Schedulers.immediate(), false);
final Future<R> f = o.toBlockingObservable().toFuture();
final Future<R> f = o.toBlocking().toFuture();

/* special handling of error states that throw immediately */
if (f.isDone()) {
Expand Down Expand Up @@ -2398,7 +2398,7 @@ public void testObserveSuccess() {
assertEquals(0, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE));
assertEquals(0, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));
assertEquals(0, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS));
assertEquals(true, command.observe().toBlockingObservable().single());
assertEquals(true, command.observe().toBlocking().single());
assertEquals(0, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.FAILURE));
assertEquals(0, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.TIMEOUT));
assertEquals(1, command.builder.metrics.getRollingCount(HystrixRollingNumberEvent.SUCCESS));
Expand Down Expand Up @@ -3234,7 +3234,7 @@ public void testQueuedExecutionTimeoutFallbackFailure() {
public void testObservedExecutionTimeoutWithNoFallback() {
TestHystrixCommand<Boolean> command = new TestCommandWithTimeout(50, TestCommandWithTimeout.FALLBACK_NOT_IMPLEMENTED);
try {
command.observe().toBlockingObservable().single();
command.observe().toBlocking().single();
fail("we shouldn't get here");
} catch (Exception e) {
e.printStackTrace();
Expand Down Expand Up @@ -3280,7 +3280,7 @@ public void testObservedExecutionTimeoutWithNoFallback() {
public void testObservedExecutionTimeoutWithFallback() {
TestHystrixCommand<Boolean> command = new TestCommandWithTimeout(50, TestCommandWithTimeout.FALLBACK_SUCCESS);
try {
assertEquals(false, command.observe().toBlockingObservable().single());
assertEquals(false, command.observe().toBlocking().single());
} catch (Exception e) {
e.printStackTrace();
fail("We should have received a response from the fallback.");
Expand Down Expand Up @@ -3313,7 +3313,7 @@ public void testObservedExecutionTimeoutWithFallback() {
public void testObservedExecutionTimeoutFallbackFailure() {
TestHystrixCommand<Boolean> command = new TestCommandWithTimeout(50, TestCommandWithTimeout.FALLBACK_FAILURE);
try {
command.observe().toBlockingObservable().single();
command.observe().toBlocking().single();
fail("we shouldn't get here");
} catch (Exception e) {
if (e instanceof HystrixRuntimeException) {
Expand Down Expand Up @@ -6146,7 +6146,7 @@ public void call(Throwable t1) {
isRequestContextInitialized.set(HystrixRequestContext.isCurrentThreadInitialized());
}

}).toBlockingObservable().single();
}).toBlocking().single();
throw new RuntimeException("expected error to be thrown");
} catch (Throwable e) {
assertTrue(isRequestContextInitialized.get());
Expand Down Expand Up @@ -6195,7 +6195,7 @@ public Observable<Boolean> call(Boolean t1) {
}

});
System.out.println("result (toObservable) = " + result.toBlockingObservable().single());
System.out.println("result (toObservable) = " + result.toBlocking().single());
}

/* ******************************************************************************** */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ public void testCache() {
HystrixRequestCache cache2 = HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command2"), strategy);
cache2.putIfAbsent("valueA", new TestObservable("a3"));

assertEquals("a1", cache1.get("valueA").toBlockingObservable().last());
assertEquals("b1", cache1.get("valueB").toBlockingObservable().last());
assertEquals("a1", cache1.get("valueA").toBlocking().last());
assertEquals("b1", cache1.get("valueB").toBlocking().last());

assertEquals("a3", cache2.get("valueA").toBlockingObservable().last());
assertEquals("a3", cache2.get("valueA").toBlocking().last());
assertNull(cache2.get("valueB"));
} catch (Exception e) {
fail("Exception: " + e.getMessage());
Expand All @@ -320,7 +320,7 @@ public void testClearCache() {
try {
HystrixRequestCache cache1 = HystrixRequestCache.getInstance(HystrixCommandKey.Factory.asKey("command1"), strategy);
cache1.putIfAbsent("valueA", new TestObservable("a1"));
assertEquals("a1", cache1.get("valueA").toBlockingObservable().last());
assertEquals("a1", cache1.get("valueA").toBlocking().last());
cache1.clear("valueA");
assertNull(cache1.get("valueA"));
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public static class UnitTest {
public void testSetResponseSuccess() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setResponse("theResponse");

Expand All @@ -250,7 +250,7 @@ public void testSetResponseSuccess() throws InterruptedException, ExecutionExcep
public void testSetNullResponseSuccess() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setResponse(null);

Expand All @@ -262,7 +262,7 @@ public void testSetNullResponseSuccess() throws InterruptedException, ExecutionE
public void testSetException() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setException(new RuntimeException("anException"));

Expand All @@ -279,7 +279,7 @@ public void testSetException() throws InterruptedException, ExecutionException {
public void testSetExceptionAfterResponse() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setResponse("theResponse");

Expand All @@ -297,7 +297,7 @@ public void testSetExceptionAfterResponse() throws InterruptedException, Executi
public void testSetResponseAfterException() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setException(new RuntimeException("anException"));

Expand All @@ -320,7 +320,7 @@ public void testSetResponseAfterException() throws InterruptedException, Executi
public void testSetResponseDuplicate() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setResponse("theResponse");

Expand All @@ -338,7 +338,7 @@ public void testSetResponseDuplicate() throws InterruptedException, ExecutionExc
public void testSetResponseAfterUnsubscribe() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> f = o.toBlockingObservable().toFuture();
Future<String> f = o.toBlocking().toFuture();

// cancel/unsubscribe
f.cancel(true);
Expand All @@ -357,7 +357,7 @@ public void testSetResponseAfterUnsubscribe() throws InterruptedException, Execu
public void testSetExceptionAfterUnsubscribe() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> f = o.toBlockingObservable().toFuture();
Future<String> f = o.toBlocking().toFuture();

// cancel/unsubscribe
f.cancel(true);
Expand All @@ -376,7 +376,7 @@ public void testSetExceptionAfterUnsubscribe() throws InterruptedException, Exec
public void testUnsubscribeAfterSetResponse() throws InterruptedException, ExecutionException {
CollapsedRequestObservableFunction<String, String> cr = new CollapsedRequestObservableFunction<String, String>("hello");
Observable<String> o = Observable.create(cr);
Future<String> v = o.toBlockingObservable().toFuture();
Future<String> v = o.toBlocking().toFuture();

cr.setResponse("theResponse");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ public void call(Throwable throwable) {
}
})
.materialize()
.toBlockingObservable().single();
.toBlocking().single();

context.shutdown();
Hystrix.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public String call(String s) {
System.out.println("Map => Commands: " + HystrixRequestLog.getCurrentRequest().getExecutedCommands());
return s;
}
}).toBlockingObservable().forEach(new Action1<String>() {
}).toBlocking().forEach(new Action1<String>() {

@Override
public void call(String s) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ public void testObservable() throws Exception {
Observable<String> fBob = new CommandHelloWorld("Bob").observe();

// blocking
assertEquals("Hello World!", fWorld.toBlockingObservable().single());
assertEquals("Hello Bob!", fBob.toBlockingObservable().single());
assertEquals("Hello World!", fWorld.toBlocking().single());
assertEquals("Hello Bob!", fBob.toBlocking().single());

// non-blocking
// - this is a verbose anonymous inner-class approach and doesn't do assertions
Expand Down