Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 6621d96

Browse files
author
Michal Gajdos
committed
Fixed minor issues in rx-client-java8-webapp example.
Change-Id: I83e918265dc013a3962cc44658685b498382cd60 Signed-off-by: Michal Gajdos <[email protected]>
1 parent de2c2f9 commit 6621d96

File tree

5 files changed

+12
-28
lines changed

5 files changed

+12
-28
lines changed

examples/rx-client-java8-webapp/src/main/java/org/glassfish/jersey/examples/rx/RxApplication.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ public RxApplication() {
6868
register(DestinationResource.class);
6969
register(CalculationResource.class);
7070
register(ForecastResource.class);
71+
7172
// Agent (Client) Resources.
72-
register(ObservableAgentResource.class);
7373
register(SyncAgentResource.class);
7474
register(AsyncAgentResource.class);
75+
register(ObservableAgentResource.class);
7576
register(ListenableFutureAgentResource.class);
7677
register(CompletionStageAgentResource.class);
7778

examples/rx-client-java8-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/AsyncAgentResource.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,20 +171,21 @@ public void failed(final Throwable throwable) {
171171

172172
final Map<String, Calculation> calculations = new HashMap<>();
173173
while (futures.size() > 0) {
174-
Iterator<Future<Calculation>> iterator = futures.iterator();
174+
final Iterator<Future<Calculation>> iterator = futures.iterator();
175+
175176
while (iterator.hasNext()) {
176-
Future<Calculation> f = iterator.next();
177+
final Future<Calculation> f = iterator.next();
177178
if (f.isDone()) {
178179
try {
179180
final Calculation calculation = f.get();
180181
calculations.put(calculation.getTo(), calculation);
181182

182-
iterator.remove();
183-
184183
innerLatch.countDown();
185184
} catch (final Throwable t) {
186185
errors.offer("Calculation: " + t.getMessage());
187186
innerLatch.countDown();
187+
} finally {
188+
iterator.remove();
188189
}
189190
}
190191
}

examples/rx-client-java8-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/ObservableAgentResource.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import java.util.concurrent.ConcurrentLinkedQueue;
4747

4848
import javax.ws.rs.GET;
49-
import javax.ws.rs.HeaderParam;
5049
import javax.ws.rs.Path;
5150
import javax.ws.rs.Produces;
5251
import javax.ws.rs.client.WebTarget;
@@ -67,10 +66,6 @@
6766
import org.glassfish.jersey.server.Uri;
6867

6968
import rx.Observable;
70-
import rx.functions.Action1;
71-
import rx.functions.Func1;
72-
import rx.functions.Func2;
73-
import rx.functions.Func3;
7469
import rx.schedulers.Schedulers;
7570

7671
/**

examples/rx-client-java8-webapp/src/main/java/org/glassfish/jersey/examples/rx/agent/SyncAgentResource.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,8 @@ public AgentResponse sync() {
9292
response.setVisited(destination.path("visited").request()
9393
// Identify the user.
9494
.header("Rx-User", "Sync")
95-
// Return a list of destinations
96-
.get(new GenericType<List<Destination>>() {
97-
}));
95+
// Return a list of destinations
96+
.get(new GenericType<List<Destination>>() {}));
9897
} catch (final Throwable throwable) {
9998
errors.offer("Visited: " + throwable.getMessage());
10099
}
@@ -106,8 +105,7 @@ public AgentResponse sync() {
106105
// Identify the user.
107106
.header("Rx-User", "Sync")
108107
// Return a list of destinations.
109-
.get(new GenericType<List<Destination>>() {
110-
});
108+
.get(new GenericType<List<Destination>>() {});
111109
} catch (final Throwable throwable) {
112110
errors.offer("Recommended: " + throwable.getMessage());
113111
}

examples/rx-client-java8-webapp/src/main/java/org/glassfish/jersey/examples/rx/remote/DestinationResource.java

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
import org.glassfish.jersey.examples.rx.domain.Destination;
5858
import org.glassfish.jersey.server.ManagedAsync;
5959

60-
import com.google.common.base.Function;
6160
import com.google.common.collect.Lists;
6261

6362
/**
@@ -91,12 +90,7 @@ public List<Destination> visited(@HeaderParam("Rx-User") @DefaultValue("KO") fin
9190
VISITED.put(user, Helper.getCountries(5));
9291
}
9392

94-
return Lists.transform(VISITED.get(user), new Function<String, Destination>() {
95-
@Override
96-
public Destination apply(final String input) {
97-
return new Destination(input);
98-
}
99-
});
93+
return Lists.transform(VISITED.get(user), Destination::new);
10094
}
10195

10296
@GET
@@ -111,11 +105,6 @@ public List<Destination> recommended(@HeaderParam("Rx-User") @DefaultValue("KO")
111105
VISITED.put(user, Helper.getCountries(5));
112106
}
113107

114-
return Lists.transform(Helper.getCountries(limit, VISITED.get(user)), new Function<String, Destination>() {
115-
@Override
116-
public Destination apply(final String input) {
117-
return new Destination(input);
118-
}
119-
});
108+
return Lists.transform(Helper.getCountries(limit, VISITED.get(user)), Destination::new);
120109
}
121110
}

0 commit comments

Comments
 (0)