Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
package com.abbyy.rtr.ui.sample.imagecapture.flexicapture;
import org.junit.Rule;
import org.junit.Test;
import java.util.concurrent.CountDownLatch;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.mockwebserver.MockResponse;
import okhttp3.mockwebserver.MockWebServer;
public class OkHttpBug {
@Rule public final MockWebServer server = new MockWebServer();
public void test() throws Exception
server.enqueue( new MockResponse()
.addHeader( "Content-Type: text/plain" )
.setBody( "abc" ) );
Request request = new Request.Builder()
.url( server.url( "`" ) )
.header( "User-Agent", "Test Case" )
OkHttpClient client = new OkHttpClient();
Call call = client.newCall( request );
CountDownLatch countDownLatch = new CountDownLatch( 1 );
call.enqueue( new Callback() {
public void onFailure( Call call, IOException e )
// Never called
public void onResponse( Call call, Response response ) throws IOException
// Never called
} );
// RuntimeException(URISyntaxException) is thrown on WorkerThread. Android app is crashed.
// Waiting forever...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment