未验证 提交 f288fef3 编写于 作者: J Jake Wharton 提交者: GitHub

Merge pull request #3346 from square/jakew/gradle/2020-03-25

Small fixes from error-prone
......@@ -234,7 +234,7 @@ final class OkHttpCall<T> implements Call<T> {
}
}
public void cancel() {
@Override public void cancel() {
canceled = true;
okhttp3.Call call;
......
......@@ -787,7 +787,7 @@ public final class CallTest {
Object a = new Object() {
@Override public String toString() {
writeCount.incrementAndGet();
throw new Error("Broken!");
throw new NonFatalError("Broken!");
}
};
Call<String> call = service.postRequestBody(a);
......@@ -795,7 +795,7 @@ public final class CallTest {
try {
call.request();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......@@ -803,7 +803,7 @@ public final class CallTest {
try {
call.execute();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......@@ -882,7 +882,7 @@ public final class CallTest {
Object a = new Object() {
@Override public String toString() {
writeCount.incrementAndGet();
throw new Error("Broken!");
throw new NonFatalError("Broken!");
}
};
Call<String> call = service.postRequestBody(a);
......@@ -890,7 +890,7 @@ public final class CallTest {
try {
call.execute();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......@@ -898,7 +898,7 @@ public final class CallTest {
try {
call.request();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......@@ -993,7 +993,7 @@ public final class CallTest {
Object a = new Object() {
@Override public String toString() {
writeCount.incrementAndGet();
throw new Error("Broken!");
throw new NonFatalError("Broken!");
}
};
Call<String> call = service.postRequestBody(a);
......@@ -1001,7 +1001,7 @@ public final class CallTest {
try {
call.request();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......@@ -1012,7 +1012,7 @@ public final class CallTest {
}
@Override public void onFailure(Call<String> call, Throwable t) {
assertThat(t).isExactlyInstanceOf(Error.class).hasMessage("Broken!");
assertThat(t).isExactlyInstanceOf(NonFatalError.class).hasMessage("Broken!");
assertThat(writeCount.get()).isEqualTo(1);
latch.countDown();
}
......@@ -1110,7 +1110,7 @@ public final class CallTest {
Object a = new Object() {
@Override public String toString() {
writeCount.incrementAndGet();
throw new Error("Broken!");
throw new NonFatalError("Broken!");
}
};
Call<String> call = service.postRequestBody(a);
......@@ -1121,7 +1121,7 @@ public final class CallTest {
}
@Override public void onFailure(Call<String> call, Throwable t) {
assertThat(t).isExactlyInstanceOf(Error.class).hasMessage("Broken!");
assertThat(t).isExactlyInstanceOf(NonFatalError.class).hasMessage("Broken!");
assertThat(writeCount.get()).isEqualTo(1);
latch.countDown();
}
......@@ -1131,7 +1131,7 @@ public final class CallTest {
try {
call.request();
fail();
} catch (Error e) {
} catch (NonFatalError e) {
assertThat(e).hasMessage("Broken!");
}
assertThat(writeCount.get()).isEqualTo(1);
......
/*
* Copyright (C) 2020 Square, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package retrofit2;
final class NonFatalError extends Error {
NonFatalError(String message) {
super(message);
}
}
......@@ -32,6 +32,7 @@ import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.ResponseBody;
import okio.Buffer;
import org.junit.Ignore;
import org.junit.Test;
import retrofit2.helpers.NullObjectConverterFactory;
import retrofit2.helpers.ToStringConverterFactory;
......@@ -793,6 +794,7 @@ public final class RequestFactoryTest {
assertThat(request.body()).isNull();
}
@Ignore("This test is valid but isn't validated by RequestFactory so it needs moved")
@Test public void headWithoutVoidThrows() {
class Example {
@HEAD("/foo/bar/") //
......@@ -802,6 +804,7 @@ public final class RequestFactoryTest {
}
try {
buildRequest(Example.class);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(
"HEAD method must use Void as response type.\n for method Example.method");
......
......@@ -121,7 +121,8 @@ public final class RetrofitTest {
@GET("/") Call<String> method(@Query("i") AtomicInteger value);
}
@SuppressWarnings("EqualsBetweenInconvertibleTypes") // We are explicitly testing this behavior.
// We are explicitly testing this behavior.
@SuppressWarnings({"EqualsBetweenInconvertibleTypes", "EqualsIncompatibleType"})
@Test public void objectMethodsStillWork() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(server.url("/"))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册