Skip to content

Commit 619344f

Browse files
committed
fix(routes): resolve background single-thread deadlock in Java RoutesActivity
1 parent 4338fee commit 619344f

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

Maps3DSamples/ApiDemos/java-app/src/main/java/com/example/maps3djava/routes/RoutesActivity.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ public final Camera getInitialCamera() {
118118
// Background Executors
119119
private final ExecutorService executorService = Executors.newSingleThreadExecutor();
120120
private final Handler mainHandler = new Handler(Looper.getMainLooper());
121-
private Future<RouteData> routeFetchFuture;
122121

123122
@Override
124123
protected void onCreate(Bundle savedInstanceState) {
@@ -241,8 +240,7 @@ private void loadAndRenderRouteAsync(GoogleMap3D googleMap3D) {
241240
if (apiKey.isEmpty() || apiKey.contains("YOUR_API_KEY")) {
242241
throw new Exception("Invalid or missing API Key");
243242
}
244-
routeFetchFuture = executorService.submit(routeRepository.fetchRouteCallable(apiKey, origin, destination));
245-
RouteData routeData = routeFetchFuture.get();
243+
RouteData routeData = routeRepository.fetchRouteCallable(apiKey, origin, destination).call();
246244
decoded = PolyUtil.decode(routeData.getEncodedPolyline());
247245
} catch (Exception e) {
248246
Log.w(getTAG(), "Routes API fetch failed (" + e.getLocalizedMessage() + "). Falling back to pre-baked Oahu mountain route.");

0 commit comments

Comments
 (0)