Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ tomcat.8080
.classpath
.settings/
bin/
classes
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ Add the following Maven/Gradle dependencies:
| [Spring Security](http://projects.spring.io/spring-security/) configuration support for fibers. | `co.paralleluniverse:comsat-spring-security:0.7.0`
| [JAX-RS client](https://jersey.java.net/documentation/latest/client.html) integration for HTTP calls with fibers. | `co.paralleluniverse:comsat-jax-rs-client:0.7.0`
| [ApacheHttpClient](http://hc.apache.org/httpcomponents-client-ga/) integration for HTTP calls with fibers. | `co.paralleluniverse:comsat-httpclient:0.7.0`
| [Retrofit](http://square.github.io/retrofit/) integration with fibers. | `co.paralleluniverse:comsat-retrofit:0.7.0`
| [JDBI](http://jdbi.org/) integration with fibers. | `co.paralleluniverse:comsat-jdbi:0.7.0`
| JDBC integration with fibers. | `co.paralleluniverse:comsat-jdbc:0.7.0`
| [jOOQ](http://www.jooq.org/) integration with fibers. | `co.paralleluniverse:comsat-jooq:0.7.0`
Expand Down
72 changes: 46 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ subprojects {
ext.metricsVer = '3.1.2'
ext.asmVer = '5.0.4'

ext.quasarVer = '0.7.6'
ext.quasarVer = '0.7.7'

ext.jettyVer = '9.2.14.v20151106' // '9.3.x' requires JDK8
ext.tomcatVer = '8.0.33'
Expand All @@ -63,13 +63,12 @@ subprojects {
ext.dropwizardVer = '0.9.2'
ext.jdbiVer = '2.72'

ext.retrofitVer = '1.9.0'
ext.jooqVer = '3.6.4' // 3jooq.7.x support only Java 8+
ext.slf4jApiVer = '1.7.21'
ext.log4jVer = '1.2.17'
ext.guavaVer = '19.0'

ext.okhttpVer = '2.6.0' // TODO Upgrade to 3.2.x
ext.okhttpVer = '3.6.0'

ext.apacheAsyncClientVer = '4.1.1'
ext.httpCoreVer = '4.4.4'
Expand Down Expand Up @@ -231,6 +230,33 @@ subprojects {
}
}

compileJava.dependsOn processResources
compileJava {
doLast {
ant.taskdef(
name:'instrumentation',
classname:'co.paralleluniverse.fibers.instrument.InstrumentationTask',
classpath: "build/classes/main:build/resources/main:${configurations.provided.asPath}:${configurations.runtime.asPath}")

ant.instrumentation(verbose:'true', check:'true', debug:'true') {
fileset(dir: sourceSets.main.output.classesDir)
}
}
}
compileTestJava.dependsOn processTestResources
compileTestJava {
doLast {
ant.taskdef(
name:'instrumentation',
classname:'co.paralleluniverse.fibers.instrument.InstrumentationTask',
classpath: "build/classes/main:build/resources/main:${configurations.provided.asPath}:${configurations.runtime.asPath}")
ant.instrumentation(verbose:'true', check:'true', debug:'true') {
fileset(dir: sourceSets.test.output.classesDir)
}
}
}


tasks.withType(Test) {
// systemProperty 'co.paralleluniverse.fibers.verifyInstrumentation', 'true'
// systemProperty 'co.paralleluniverse.fibers.detectRunawayFibers', 'false'
Expand Down Expand Up @@ -418,12 +444,25 @@ project (':comsat-mongodb-allanbank') {
}

project (':comsat-okhttp') {

configurations {
alpn
}

dependencies {
compile "com.squareup.okhttp:okhttp:$okhttpVer"
compile "com.squareup.okhttp:okhttp-urlconnection:$okhttpVer"
compile "com.squareup.okhttp:okhttp-apache:$okhttpVer"
compile "com.squareup.okhttp3:okhttp:$okhttpVer"
compile "com.squareup.okhttp3:okhttp-urlconnection:$okhttpVer"
compile "com.squareup.okhttp3:okhttp-apache:$okhttpVer"
compile project (':comsat-httpclient')
testCompile "com.squareup.okhttp:mockwebserver:$okhttpVer"
testCompile "com.squareup.okhttp3:mockwebserver:$okhttpVer"
testCompile "com.squareup.okhttp3:okhttp-testing-support:$okhttpVer"

//http://www.eclipse.org/jetty/documentation/current/alpn-chapter.html#alpn-versions
alpn 'org.mortbay.jetty.alpn:alpn-boot:8.1.9.v20160720'
}

test {
jvmArgs = ['-Xbootclasspath/p:' + configurations.alpn.resolve().first()]
}
}

Expand All @@ -441,24 +480,6 @@ project (':comsat-shiro') {
}
}

project (':comsat-retrofit') {
dependencies {
compile "com.squareup.retrofit:retrofit:$retrofitVer"
compile project (':comsat-httpclient')
compile project (':comsat-okhttp')
testCompile (project (':comsat-dropwizard')) {
exclude group: 'org.jboss.logging', module: 'jboss-logging'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
}
testCompile (project(':comsat-test-utils')) {
exclude group: 'org.eclipse.jetty', module: '*'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'org.apache.tomcat', module: 'tomcat-juli'
// exclude group: 'org.apache.tomcat', module: 'tomcat-dbcp'
}
}
}

project (':comsat-servlet') { // TODO Check seemingly harmless exceptions during tests
dependencies {
testRuntime "ch.qos.logback:logback-classic:1.1.3"
Expand Down Expand Up @@ -528,7 +549,6 @@ ext.javadocLinks = [
"http://hc.apache.org/httpcomponents-client-4.5.x/httpclient/apidocs/",
"http://hc.apache.org/httpcomponents-asyncclient-4.1.x/httpasyncclient/apidocs/",
"http://hc.apache.org/httpcomponents-core-4.4.x/httpcore/apidocs/",
"http://square.github.io/retrofit/1.x/retrofit/",
"http://jdbi.org/apidocs/",
"http://www.jooq.org/javadoc/3.6.x/",
"http://docs.oracle.com/javase/7/docs/api/",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,21 @@
*/
package co.paralleluniverse.fibers.okhttp;

import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkHttpClient;
import com.squareup.okhttp.Request;
import okhttp3.Call;
import okhttp3.FiberCall;
import okhttp3.OkHttpClient;
import okhttp3.Request;

/**
* Fiber-blocking OkHttp's {@link OkHttpClient} implementation.
*
* @author circlespainter
*/
public class FiberOkHttpClient extends OkHttpClient {
public class FiberOkHttpClient extends OkHttpClient
{

@Override
public Call newCall(Request request) {
return new FiberCall(this, request);
return new FiberCall(this, request, false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,67 +16,81 @@
import co.paralleluniverse.fibers.FiberUtil;
import co.paralleluniverse.fibers.SuspendExecution;
import co.paralleluniverse.strands.SuspendableCallable;
import com.squareup.okhttp.Call;
import com.squareup.okhttp.OkUrlFactory;
import com.squareup.okhttp.Request;
import com.squareup.okhttp.Response;
import com.squareup.okhttp.apache.OkApacheClient;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

import okhttp3.Call;
import okhttp3.OkUrlFactory;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.apache.OkApacheClient;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpRequestBase;

/**
*
* @author circlespainter
*/
public class FiberOkHttpUtil {
public static Response executeInFiber(final FiberOkHttpClient client, final Request request) throws InterruptedException, IOException {
return FiberOkHttpUtil.executeInFiber(client.newCall(request));
}
public class FiberOkHttpUtil
{
public static Response executeInFiber(final FiberOkHttpClient client, final Request request) throws InterruptedException, IOException
{
return FiberOkHttpUtil.executeInFiber(client.newCall(request));
}

public static Response executeInFiber(final Call call) throws InterruptedException, IOException {
return FiberUtil.runInFiberChecked (
new SuspendableCallable<Response>() {
@Override
public Response run() throws SuspendExecution, InterruptedException {
try {
return call.execute();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
public static Response executeInFiber(final Call call) throws InterruptedException, IOException
{
return FiberUtil.runInFiberChecked(new SuspendableCallable<Response>()
{
@Override
public Response run() throws SuspendExecution, InterruptedException
{
try
{
return call.execute();
}
catch (IOException ex)
{
throw new RuntimeException(ex);
}
}, IOException.class
);
}
}, IOException.class);
}

public static HttpURLConnection openInFiber(final OkUrlFactory factory, final URL url) throws InterruptedException {
return FiberUtil.runInFiberRuntime (
new SuspendableCallable<HttpURLConnection>() {
@Override
public HttpURLConnection run() throws SuspendExecution, InterruptedException {
return factory.open(url);
}
public static HttpURLConnection openInFiber(final OkUrlFactory factory, final URL url) throws InterruptedException
{
return FiberUtil.runInFiberRuntime(new SuspendableCallable<HttpURLConnection>()
{
@Override
public HttpURLConnection run() throws SuspendExecution, InterruptedException
{
return factory.open(url);
}
);
});
}

public static HttpResponse executeInFiber(final OkApacheClient client, final HttpRequestBase req) throws InterruptedException, IOException {
return FiberUtil.runInFiberChecked (
new SuspendableCallable<HttpResponse>() {
@Override
public HttpResponse run() throws SuspendExecution, InterruptedException {
try {
return client.execute(req);
} catch (IOException ex) {
throw new RuntimeException(ex);
}
public static HttpResponse executeInFiber(final OkApacheClient client, final HttpRequestBase req) throws InterruptedException, IOException
{
return FiberUtil.runInFiberChecked(new SuspendableCallable<HttpResponse>()
{
@Override
public HttpResponse run() throws SuspendExecution, InterruptedException
{
try
{
return client.execute(req);
}
}, IOException.class
);
catch (IOException ex)
{
throw new RuntimeException(ex);
}
}
}, IOException.class);
}

private FiberOkHttpUtil() {
private FiberOkHttpUtil()
{
}
}
25 changes: 0 additions & 25 deletions comsat-okhttp/src/main/java/com/squareup/okhttp/CallProxy.java

This file was deleted.

Loading