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

Simple application never finishes #615

Closed
matthjes opened this issue Oct 2, 2019 · 3 comments
Closed

Simple application never finishes #615

matthjes opened this issue Oct 2, 2019 · 3 comments
Labels
needs more info This issue needs more information from the customer to proceed. stale triage me I really want to be triaged.

Comments

@matthjes
Copy link

matthjes commented Oct 2, 2019

Environment details

  1. Geocoding
  2. Windows 10
  3. JDK 11, Geocoding API 0.10.0, OKHTTP 4.2.0, Gson 2.8.5

Steps to reproduce

  1. Run minimal example found below.
  2. Application runs and fetches geolocation, but never finishes (background threads are still running?)

Code example

Main class:

public class Main {

    private static final Logger LOG = LoggerFactory.getLogger(Main.class);

    public static void main(String[] args) throws InterruptedException, ExecutionException {

        GoogleGeocodeService service = new GoogleGeocodeService("<key>");

        LOG.info("Resolving address...");
        CompletableFuture<GeocodingResult> result = service.resolve(new GeoLocation(48.120601, 11.605407));

        boolean[] ready = {false};
        result.thenAccept(geoResult -> {
            LOG.info("Result ready...");
            LOG.info("Result: {}", geoResult);
            ready[0] = true;
        });

        while (!ready[0]) {
            LOG.info("Sleeping");
            Thread.sleep(1000);
        }
        LOG.info("Finished");
    }
}

Service:

public class GoogleGeocodeService implements GeocodeService {

    private static final Logger LOG = LoggerFactory.getLogger(GoogleGeocodeService.class);

    private final GeoApiContext context;

    public GoogleGeocodeService(String apiKey) {
        this.context = new GeoApiContext.Builder()
                .apiKey(apiKey)
                .disableRetries()
                .readTimeout(5, TimeUnit.SECONDS)
                .retryTimeout(5, TimeUnit.SECONDS)
                .writeTimeout(5, TimeUnit.SECONDS)
                .connectTimeout(5, TimeUnit.SECONDS)
                .build();
    }

    @Override
    public CompletableFuture<GeocodingResult> resolve(GeoLocation location) {
        CompletableFuture<GeocodingResult> result = new CompletableFuture<>();
        LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
        GeocodingApiRequest request = GeocodingApi.reverseGeocode(this.context, latLng);

        request.setCallback(new PendingResult.Callback<GeocodingResult[]>() {
            @Override
            public void onResult(GeocodingResult[] geocodingResults) {
                LOG.info("Call finished....");
                if (geocodingResults.length > 0) {
                    result.complete(geocodingResults[0]);
                }
                LOG.info("Finished task...");
            }

            @Override
            public void onFailure(Throwable throwable) {
                result.completeExceptionally(throwable);
            }
        });
        return result;
    }
}

Output

12:26:03.724 [main] INFO  de.matthjes.playground.geocode.Main - Resolving address...
12:26:03.757 [main] INFO  de.matthjes.playground.geocode.Main - Sleeping
12:26:04.306 [OkHttp https://maps.googleapis.com/...] INFO  d.m.p.geocode.GoogleGeocodeService - Call finished....
12:26:04.307 [OkHttp https://maps.googleapis.com/...] INFO  de.matthjes.playground.geocode.Main - Result ready...
12:26:04.307 [OkHttp https://maps.googleapis.com/...] INFO  de.matthjes.playground.geocode.Main - Result: [GeocodingResult placeId=ChIJEf7m3JrfnUcRVQNmNu7XD_o [Geometry: 48.12054220,11.60502930 (ROOFTOP) bounds=null, viewport=[48.12189118,11.60637828, 48.11919322,11.60368032]], formattedAddress=St.-Martin-Straße 110, 81669 München, Germany, types=[street_address], addressComponents=[[AddressComponent: "110" ("110") (street_number)], [AddressComponent: "St.-Martin-Straße" ("St.-Martin-Straße") (route)], [AddressComponent: "Ramersdorf-Perlach" ("Ramersdorf-Perlach") (political, sublocality, sublocality_level_1)], [AddressComponent: "München" ("München") (locality, political)], [AddressComponent: "Oberbayern" ("Oberbayern") (administrative_area_level_2, political)], [AddressComponent: "Bayern" ("BY") (administrative_area_level_1, political)], [AddressComponent: "Germany" ("DE") (country, political)], [AddressComponent: "81669" ("81669") (postal_code)]]]
12:26:04.309 [OkHttp https://maps.googleapis.com/...] INFO  d.m.p.geocode.GoogleGeocodeService - Finished task...
12:26:04.757 [main] INFO  de.matthjes.playground.geocode.Main - Finished

Stack trace

Full thread dump

"Rate Limited Dispatcher@2358" daemon prio=5 tid=0x12 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
	  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
	  at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:460)
	  at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:361)
	  at java.util.concurrent.SynchronousQueue.take(SynchronousQueue.java:920)
	  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

"OkHttp maps.googleapis.com Writer@3074" prio=5 tid=0x16 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
	  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
	  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
	  at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:1170)
	  at java.util.concurrent.ScheduledThreadPoolExecutor$DelayedWorkQueue.take(ScheduledThreadPoolExecutor.java:899)
	  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1054)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

"OkHttp Http2Connection@3077" daemon prio=5 tid=0x17 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
	  at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234)
	  at java.util.concurrent.SynchronousQueue$TransferStack.awaitFulfill(SynchronousQueue.java:462)
	  at java.util.concurrent.SynchronousQueue$TransferStack.transfer(SynchronousQueue.java:361)
	  at java.util.concurrent.SynchronousQueue.poll(SynchronousQueue.java:937)
	  at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1053)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1114)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

"OkHttp ConnectionPool@3020" daemon prio=5 tid=0x14 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at java.lang.Object.wait(Object.java:-1)
	  at java.lang.Object.wait(Object.java:462)
	  at okhttp3.internal.Util.waitMillis(Util.kt:536)
	  at okhttp3.internal.Util.lockAndWaitNanos(Util.kt:522)
	  at okhttp3.internal.connection.RealConnectionPool$cleanupRunnable$1.run(RealConnectionPool.kt:49)
	  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	  at java.lang.Thread.run(Thread.java:834)

"RateLimitExecutorDelayThread@1687" daemon prio=5 tid=0x10 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
	  at java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
	  at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2081)
	  at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:433)
	  at com.google.maps.internal.RateLimitExecutorService.run(RateLimitExecutorService.java:78)
	  at java.lang.Thread.run(Thread.java:834)

"Common-Cleaner@1667" daemon prio=8 tid=0xb nid=NA waiting
  java.lang.Thread.State: WAITING
	  at java.lang.Object.wait(Object.java:-1)
	  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
	  at jdk.internal.ref.CleanerImpl.run(CleanerImpl.java:148)
	  at java.lang.Thread.run(Thread.java:834)
	  at jdk.internal.misc.InnocuousThread.run(InnocuousThread.java:134)

"Okio Watchdog@3042" daemon prio=5 tid=0x15 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at java.lang.Object.wait(Object.java:-1)
	  at okio.AsyncTimeout$Companion.awaitTimeout$jvm(AsyncTimeout.kt:342)
	  at okio.AsyncTimeout$Watchdog.run(AsyncTimeout.kt:229)

"OkHttp maps.googleapis.com@3019" daemon prio=5 tid=0x13 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	  at java.net.SocketInputStream.socketRead0(SocketInputStream.java:-1)
	  at java.net.SocketInputStream.socketRead(SocketInputStream.java:115)
	  at java.net.SocketInputStream.read(SocketInputStream.java:168)
	  at java.net.SocketInputStream.read(SocketInputStream.java:140)
	  at sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:448)
	  at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(SSLSocketInputRecord.java:68)
	  at sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1104)
	  at sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:823)
	  - locked <0xcd5> (a sun.security.ssl.SSLSocketImpl$AppInputStream)
	  at okio.InputStreamSource.read(Okio.kt:102)
	  at okio.AsyncTimeout$source$1.read(AsyncTimeout.kt:159)
	  at okio.RealBufferedSource.request(RealBufferedSource.kt:62)
	  at okio.RealBufferedSource.require(RealBufferedSource.kt:55)
	  at okhttp3.internal.http2.Http2Reader.nextFrame(Http2Reader.kt:88)
	  at okhttp3.internal.http2.Http2Connection$ReaderRunnable.run(Http2Connection.kt:567)
	  at java.lang.Thread.run(Thread.java:834)

"Reference Handler@3279" daemon prio=10 tid=0x2 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
	  at java.lang.ref.Reference.waitForReferencePendingList(Reference.java:-1)
	  at java.lang.ref.Reference.processPendingReferences(Reference.java:241)
	  at java.lang.ref.Reference$ReferenceHandler.run(Reference.java:213)

"Finalizer@3280" daemon prio=8 tid=0x3 nid=NA waiting
  java.lang.Thread.State: WAITING
	  at java.lang.Object.wait(Object.java:-1)
	  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:155)
	  at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:176)
	  at java.lang.ref.Finalizer$FinalizerThread.run(Finalizer.java:170)

"Signal Dispatcher@3281" daemon prio=9 tid=0x4 nid=NA runnable
  java.lang.Thread.State: RUNNABLE

"Attach Listener@3282" daemon prio=5 tid=0x5 nid=NA runnable
  java.lang.Thread.State: RUNNABLE

"DestroyJavaVM@3278" prio=5 tid=0x18 nid=NA runnable
  java.lang.Thread.State: RUNNABLE
@jpoehnelt jpoehnelt added the triage me I really want to be triaged. label Oct 3, 2019
@jpoehnelt
Copy link
Contributor

I'm assuming this is related to #261?

@jpoehnelt jpoehnelt added the needs more info This issue needs more information from the customer to proceed. label Oct 15, 2019
@stale
Copy link

stale bot commented Feb 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. Please comment here if it is still valid so that we can reprioritize. Thank you!

@stale stale bot added the stale label Feb 12, 2020
@stale
Copy link

stale bot commented Aug 11, 2020

Closing this. Please reopen if you believe it should be addressed. Thank you for your contribution.

@stale stale bot closed this as completed Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info This issue needs more information from the customer to proceed. stale triage me I really want to be triaged.
Projects
None yet
Development

No branches or pull requests

2 participants