mirror of
https://github.com/square/okhttp.git
synced 2025-08-07 12:42:57 +03:00
Make error-prone validate missing override annotations
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import net.ltgt.gradle.errorprone.CheckSeverity
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.versions = [
|
ext.versions = [
|
||||||
'airline': '0.8',
|
'airline': '0.8',
|
||||||
@@ -127,6 +129,11 @@ subprojects { project ->
|
|||||||
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
|
errorproneJavac 'com.google.errorprone:javac:9+181-r4173-1'
|
||||||
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
|
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
|
||||||
}
|
}
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.errorprone {
|
||||||
|
check("MissingOverride", CheckSeverity.ERROR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
apply plugin: 'org.jetbrains.dokka'
|
apply plugin: 'org.jetbrains.dokka'
|
||||||
dokka {
|
dokka {
|
||||||
|
@@ -220,7 +220,7 @@ public final class LoggingEventListenerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static class LogRecorder extends HttpLoggingInterceptorTest.LogRecorder {
|
private static class LogRecorder extends HttpLoggingInterceptorTest.LogRecorder {
|
||||||
LogRecorder assertLogMatch(String pattern) {
|
@Override LogRecorder assertLogMatch(String pattern) {
|
||||||
return (LogRecorder) super.assertLogMatch("\\[\\d+ ms] " + pattern);
|
return (LogRecorder) super.assertLogMatch("\\[\\d+ ms] " + pattern);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -287,6 +287,7 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
|
|
||||||
// Java 9 methods.
|
// Java 9 methods.
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingOverride") // Can only override with JDK 9+
|
||||||
public SSLSession getHandshakeSession() {
|
public SSLSession getHandshakeSession() {
|
||||||
try {
|
try {
|
||||||
return (SSLSession) SSLSocket.class.getMethod("getHandshakeSession").invoke(delegate);
|
return (SSLSession) SSLSocket.class.getMethod("getHandshakeSession").invoke(delegate);
|
||||||
@@ -295,6 +296,7 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingOverride") // Can only override with JDK 9+
|
||||||
public String getApplicationProtocol() {
|
public String getApplicationProtocol() {
|
||||||
try {
|
try {
|
||||||
return (String) SSLSocket.class.getMethod("getApplicationProtocol").invoke(delegate);
|
return (String) SSLSocket.class.getMethod("getApplicationProtocol").invoke(delegate);
|
||||||
@@ -303,6 +305,7 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingOverride") // Can only override with JDK 9+
|
||||||
public String getHandshakeApplicationProtocol() {
|
public String getHandshakeApplicationProtocol() {
|
||||||
try {
|
try {
|
||||||
return (String) SSLSocket.class.getMethod("getHandshakeApplicationProtocol").invoke(delegate);
|
return (String) SSLSocket.class.getMethod("getHandshakeApplicationProtocol").invoke(delegate);
|
||||||
@@ -311,6 +314,7 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("MissingOverride") // Can only override with JDK 9+
|
||||||
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException {
|
public <T> Socket setOption(SocketOption<T> name, T value) throws IOException {
|
||||||
try {
|
try {
|
||||||
SSLSocket.class.getMethod("setOption", SocketOption.class, Object.class).invoke(delegate, name, value);
|
SSLSocket.class.getMethod("setOption", SocketOption.class, Object.class).invoke(delegate, name, value);
|
||||||
@@ -320,7 +324,10 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked") // Using reflection to delegate.
|
@SuppressWarnings({
|
||||||
|
"MissingOverride", // Can only override with JDK 9+
|
||||||
|
"unchecked" // Using reflection to delegate.
|
||||||
|
})
|
||||||
public <T> T getOption(SocketOption<T> name) throws IOException {
|
public <T> T getOption(SocketOption<T> name) throws IOException {
|
||||||
try {
|
try {
|
||||||
return (T) SSLSocket.class.getMethod("getOption", SocketOption.class).invoke(delegate, name);
|
return (T) SSLSocket.class.getMethod("getOption", SocketOption.class).invoke(delegate, name);
|
||||||
@@ -329,7 +336,10 @@ public abstract class DelegatingSSLSocket extends SSLSocket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked") // Using reflection to delegate.
|
@SuppressWarnings({
|
||||||
|
"MissingOverride", // Can only override with JDK 9+
|
||||||
|
"unchecked" // Using reflection to delegate.
|
||||||
|
})
|
||||||
public Set<SocketOption<?>> supportedOptions() {
|
public Set<SocketOption<?>> supportedOptions() {
|
||||||
try {
|
try {
|
||||||
return (Set<SocketOption<?>>) SSLSocket.class.getMethod("supportedOptions").invoke(delegate);
|
return (Set<SocketOption<?>>) SSLSocket.class.getMethod("supportedOptions").invoke(delegate);
|
||||||
|
@@ -746,24 +746,24 @@ public final class URLConnectionTest {
|
|||||||
|
|
||||||
private void testConnectViaSocketFactory(boolean useHttps) throws IOException {
|
private void testConnectViaSocketFactory(boolean useHttps) throws IOException {
|
||||||
SocketFactory uselessSocketFactory = new SocketFactory() {
|
SocketFactory uselessSocketFactory = new SocketFactory() {
|
||||||
public Socket createSocket() {
|
@Override public Socket createSocket() {
|
||||||
throw new IllegalArgumentException("useless");
|
throw new IllegalArgumentException("useless");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socket createSocket(InetAddress host, int port) {
|
@Override public Socket createSocket(InetAddress host, int port) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socket createSocket(InetAddress address, int port, InetAddress localAddress,
|
@Override public Socket createSocket(InetAddress address, int port, InetAddress localAddress,
|
||||||
int localPort) {
|
int localPort) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socket createSocket(String host, int port) {
|
@Override public Socket createSocket(String host, int port) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Socket createSocket(String host, int port, InetAddress localHost, int localPort) {
|
@Override public Socket createSocket(String host, int port, InetAddress localHost, int localPort) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -3807,15 +3807,15 @@ public final class URLConnectionTest {
|
|||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public X509Certificate[] getAcceptedIssuers() {
|
@Override public X509Certificate[] getAcceptedIssuers() {
|
||||||
return delegate.getAcceptedIssuers();
|
return delegate.getAcceptedIssuers();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
@Override public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||||
calls.add("checkClientTrusted " + certificatesToString(chain));
|
calls.add("checkClientTrusted " + certificatesToString(chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
@Override public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||||
calls.add("checkServerTrusted " + certificatesToString(chain));
|
calls.add("checkServerTrusted " + certificatesToString(chain));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -306,13 +306,13 @@ class UrlComponentEncodingTester {
|
|||||||
|
|
||||||
public enum Encoding {
|
public enum Encoding {
|
||||||
IDENTITY {
|
IDENTITY {
|
||||||
public String encode(int codePoint) {
|
@Override public String encode(int codePoint) {
|
||||||
return new String(new int[] {codePoint}, 0, 1);
|
return new String(new int[] {codePoint}, 0, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
PERCENT {
|
PERCENT {
|
||||||
public String encode(int codePoint) {
|
@Override public String encode(int codePoint) {
|
||||||
ByteString utf8 = ByteString.encodeUtf8(IDENTITY.encode(codePoint));
|
ByteString utf8 = ByteString.encodeUtf8(IDENTITY.encode(codePoint));
|
||||||
Buffer percentEncoded = new Buffer();
|
Buffer percentEncoded = new Buffer();
|
||||||
for (int i = 0; i < utf8.size(); i++) {
|
for (int i = 0; i < utf8.size(); i++) {
|
||||||
|
Reference in New Issue
Block a user