Skip to content
Permalink
Browse files

Merge pull request #3132 from square/jakew/updates/2019-06-22

Update to Java 8 and OkHttp 3.14
  • Loading branch information...
swankjesse committed Jul 3, 2019
2 parents 06978cc + 8c487d4 commit 2851c14578a7722da56fabbee8d71e1c8e50c145
Showing with 357 additions and 672 deletions.
  1. +1 −1 README.md
  2. +5 −5 pom.xml
  3. +1 −1 retrofit-adapters/guava/pom.xml
  4. +4 −13 retrofit-adapters/guava/src/test/java/retrofit2/adapter/guava/StringConverterFactory.java
  5. +1 −13 retrofit-adapters/java8/pom.xml
  6. +4 −13 retrofit-adapters/java8/src/test/java/retrofit2/adapter/java8/StringConverterFactory.java
  7. +1 −1 retrofit-adapters/pom.xml
  8. +1 −1 retrofit-adapters/rxjava/pom.xml
  9. +1 −7 retrofit-adapters/rxjava/src/test/java/retrofit2/adapter/rxjava/ObservableTest.java
  10. +4 −13 retrofit-adapters/rxjava/src/test/java/retrofit2/adapter/rxjava/StringConverterFactory.java
  11. +1 −1 retrofit-adapters/rxjava2/pom.xml
  12. +12 −24 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/AsyncTest.java
  13. +6 −11 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/CompletableThrowingTest.java
  14. +18 −31 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/FlowableThrowingTest.java
  15. +19 −33 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/MaybeThrowingTest.java
  16. +1 −6 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/ObservableTest.java
  17. +18 −31 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/ObservableThrowingTest.java
  18. +18 −31 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/SingleThrowingTest.java
  19. +4 −13 retrofit-adapters/rxjava2/src/test/java/retrofit2/adapter/rxjava2/StringConverterFactory.java
  20. +1 −1 retrofit-adapters/scala/pom.xml
  21. +4 −13 retrofit-adapters/scala/src/test/java/retrofit2/adapter/scala/StringConverterFactory.java
  22. +1 −1 retrofit-converters/gson/pom.xml
  23. +1 −1 retrofit-converters/guava/pom.xml
  24. +2 −6 retrofit-converters/guava/src/test/java/retrofit/converter/guava/AlwaysNullConverterFactory.java
  25. +2 −6 ...it-converters/guava/src/test/java/retrofit/converter/guava/GuavaOptionalConverterFactoryTest.java
  26. +1 −1 retrofit-converters/jackson/pom.xml
  27. +1 −13 retrofit-converters/java8/pom.xml
  28. +2 −6 retrofit-converters/java8/src/test/java/retrofit/converter/java8/AlwaysNullConverterFactory.java
  29. +1 −1 retrofit-converters/jaxb/pom.xml
  30. +1 −1 retrofit-converters/moshi/pom.xml
  31. +5 −11 retrofit-converters/moshi/src/test/java/retrofit2/converter/moshi/MoshiConverterFactoryTest.java
  32. +1 −1 retrofit-converters/pom.xml
  33. +1 −1 retrofit-converters/protobuf/pom.xml
  34. +1 −1 retrofit-converters/scalars/pom.xml
  35. +1 −1 retrofit-converters/simplexml/pom.xml
  36. +1 −1 retrofit-converters/wire/pom.xml
  37. +1 −1 retrofit-mock/pom.xml
  38. +6 −11 retrofit-mock/src/main/java/retrofit2/mock/BehaviorDelegate.java
  39. +2 −5 retrofit-mock/src/main/java/retrofit2/mock/NetworkBehavior.java
  40. +5 −7 retrofit-mock/src/test/java/retrofit2/mock/BehaviorDelegateTest.java
  41. +4 −8 retrofit-mock/src/test/java/retrofit2/mock/CallsTest.java
  42. +4 −14 retrofit-mock/src/test/java/retrofit2/mock/NetworkBehaviorTest.java
  43. +1 −1 retrofit/pom.xml
  44. +7 −13 retrofit/src/main/java/retrofit2/DefaultCallAdapterFactory.java
  45. +28 −85 retrofit/src/main/java/retrofit2/Platform.java
  46. +41 −60 retrofit/src/test/java/retrofit2/CallTest.java
  47. +1 −7 retrofit/src/test/java/retrofit2/DefaultCallAdapterFactoryTest.java
  48. +36 −26 retrofit/src/test/java/retrofit2/Java8DefaultMethodsTest.java
  49. +31 −23 retrofit/src/test/java/retrofit2/Java8DefaultStaticMethodsInValidationTest.java
  50. +2 −4 retrofit/src/test/java/retrofit2/RequestFactoryTest.java
  51. +23 −59 retrofit/src/test/java/retrofit2/RetrofitTest.java
  52. +2 −6 retrofit/src/test/java/retrofit2/helpers/ObjectInstanceConverterFactory.java
  53. +4 −13 retrofit/src/test/java/retrofit2/helpers/ToStringConverterFactory.java
  54. +1 −1 samples/pom.xml
  55. +11 −13 samples/src/main/java/com/example/retrofit/ChunkingConverter.java
@@ -13,7 +13,7 @@ Download [the latest JAR][2] or grab from Maven central at the coordinates `com.

Snapshots of the development version are available in [Sonatype's `snapshots` repository][snap].

Retrofit requires at minimum Java 7 or Android 2.3.
Retrofit requires at minimum Java 8+ or Android API 21+.


R8 / ProGuard
10 pom.xml
@@ -25,7 +25,7 @@

<groupId>com.squareup.retrofit2</groupId>
<artifactId>parent</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>Retrofit (Parent)</name>
@@ -45,12 +45,12 @@
<project.reporting.sourceEncoding>UTF-8</project.reporting.sourceEncoding>

<!-- Compilation -->
<java.version>1.7</java.version>
<java.version>1.8</java.version>
<kotlin.version>1.3.10</kotlin.version>

<!-- Dependencies -->
<android.version>4.1.1.4</android.version>
<okhttp.version>3.12.0</okhttp.version>
<okhttp.version>3.14.0</okhttp.version>
<kotlinx.coroutines.version>1.1.0</kotlinx.coroutines.version>
<animal.sniffer.version>1.14</animal.sniffer.version>

@@ -319,8 +319,8 @@
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java16</artifactId>
<version>1.1</version>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit-adapters</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -15,7 +15,6 @@
*/
package retrofit2.adapter.guava;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.MediaType;
@@ -26,21 +25,13 @@

final class StringConverterFactory extends Converter.Factory {
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
public Converter<ResponseBody, String> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
return new Converter<ResponseBody, String>() {
@Override public String convert(ResponseBody value) throws IOException {
return value.string();
}
};
return ResponseBody::string;
}

@Override public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public Converter<String, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return new Converter<String, RequestBody>() {
@Override public RequestBody convert(String value) throws IOException {
return RequestBody.create(MediaType.get("text/plain"), value);
}
};
return value -> RequestBody.create(MediaType.get("text/plain"), value);
}
}
@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit-adapters</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -53,18 +53,6 @@

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>${animal.sniffer.version}</version>
<configuration>
<signature>
<groupId>org.kaazing.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
@@ -15,7 +15,6 @@
*/
package retrofit2.adapter.java8;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.MediaType;
@@ -26,21 +25,13 @@

final class StringConverterFactory extends Converter.Factory {
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
public Converter<ResponseBody, String> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
return new Converter<ResponseBody, String>() {
@Override public String convert(ResponseBody value) throws IOException {
return value.string();
}
};
return ResponseBody::string;
}

@Override public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public Converter<String, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return new Converter<String, RequestBody>() {
@Override public RequestBody convert(String value) throws IOException {
return RequestBody.create(MediaType.get("text/plain"), value);
}
};
return value -> RequestBody.create(MediaType.get("text/plain"), value);
}
}
@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>parent</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit-adapters</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -26,7 +26,6 @@
import retrofit2.Retrofit;
import retrofit2.http.GET;
import rx.Observable;
import rx.functions.Action1;

import static okhttp3.mockwebserver.SocketPolicy.DISCONNECT_AFTER_REQUEST;
import static org.assertj.core.api.Assertions.assertThat;
@@ -139,12 +138,7 @@

final RecordingSubscriber<Response<String>> subscriber = subscriberRule.create();
service.response()
.doOnNext(new Action1<Response<String>>() {
@Override
public void call(Response<String> response) {
subscriber.unsubscribe();
}
})
.doOnNext(response -> subscriber.unsubscribe())
.subscribe(subscriber);

assertThat(subscriber.takeValue().body()).isEqualTo("Hi");
@@ -15,7 +15,6 @@
*/
package retrofit2.adapter.rxjava;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import okhttp3.MediaType;
@@ -26,21 +25,13 @@

final class StringConverterFactory extends Converter.Factory {
@Override
public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations,
public Converter<ResponseBody, String> responseBodyConverter(Type type, Annotation[] annotations,
Retrofit retrofit) {
return new Converter<ResponseBody, String>() {
@Override public String convert(ResponseBody value) throws IOException {
return value.string();
}
};
return ResponseBody::string;
}

@Override public Converter<?, RequestBody> requestBodyConverter(Type type,
@Override public Converter<String, RequestBody> requestBodyConverter(Type type,
Annotation[] parameterAnnotations, Annotation[] methodAnnotations, Retrofit retrofit) {
return new Converter<String, RequestBody>() {
@Override public RequestBody convert(String value) throws IOException {
return RequestBody.create(MediaType.get("text/plain"), value);
}
};
return value -> RequestBody.create(MediaType.get("text/plain"), value);
}
}
@@ -6,7 +6,7 @@
<parent>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit-adapters</artifactId>
<version>2.6.1-SNAPSHOT</version>
<version>2.7.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

@@ -18,7 +18,6 @@
import io.reactivex.Completable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Consumer;
import io.reactivex.observers.TestObserver;
import io.reactivex.plugins.RxJavaPlugins;
import java.io.IOException;
@@ -27,7 +26,6 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.Dispatcher;
import okhttp3.OkHttpClient;
@@ -60,16 +58,10 @@
private List<Throwable> uncaughtExceptions = new ArrayList<>();

@Before public void setUp() {
ExecutorService executorService = Executors.newCachedThreadPool(new ThreadFactory() {
@Override public Thread newThread(Runnable r) {
Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override public void uncaughtException(Thread t, Throwable e) {
uncaughtExceptions.add(e);
}
});
return thread;
}
ExecutorService executorService = Executors.newCachedThreadPool(r -> {
Thread thread = new Thread(r);
thread.setUncaughtExceptionHandler((t, e) -> uncaughtExceptions.add(e));
return thread;
});

OkHttpClient client = new OkHttpClient.Builder()
@@ -113,13 +105,11 @@

final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> errorRef = new AtomicReference<>();
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override public void accept(Throwable throwable) throws Exception {
if (!errorRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
latch.countDown();
RxJavaPlugins.setErrorHandler(throwable -> {
if (!errorRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
latch.countDown();
});

TestObserver<Void> observer = new TestObserver<>();
@@ -139,13 +129,11 @@

final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override public void accept(Throwable throwable) throws Exception {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
latch.countDown();
RxJavaPlugins.setErrorHandler(throwable -> {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
latch.countDown();
});

TestObserver<Void> observer = new TestObserver<>();
@@ -20,7 +20,6 @@
import io.reactivex.disposables.Disposable;
import io.reactivex.exceptions.CompositeException;
import io.reactivex.exceptions.Exceptions;
import io.reactivex.functions.Consumer;
import io.reactivex.plugins.RxJavaPlugins;
import java.util.concurrent.atomic.AtomicReference;
import okhttp3.mockwebserver.MockResponse;
@@ -58,11 +57,9 @@
server.enqueue(new MockResponse());

final AtomicReference<Throwable> errorRef = new AtomicReference<>();
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override public void accept(Throwable throwable) throws Exception {
if (!errorRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
RxJavaPlugins.setErrorHandler(throwable -> {
if (!errorRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
});

@@ -81,11 +78,9 @@
server.enqueue(new MockResponse().setResponseCode(404));

final AtomicReference<Throwable> pluginRef = new AtomicReference<>();
RxJavaPlugins.setErrorHandler(new Consumer<Throwable>() {
@Override public void accept(Throwable throwable) throws Exception {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
RxJavaPlugins.setErrorHandler(throwable -> {
if (!pluginRef.compareAndSet(null, throwable)) {
throw Exceptions.propagate(throwable); // Don't swallow secondary errors!
}
});

0 comments on commit 2851c14

Please sign in to comment.
You can’t perform that action at this time.