Skip to content
Merged
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
13 changes: 10 additions & 3 deletions build-logic/src/main/kotlin/okhttp.quality-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.withType
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSniffer
import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension

plugins {
id("okhttp.base-conventions")
Expand Down Expand Up @@ -55,6 +53,15 @@ configure<AnimalSnifferExtension> {

signatures = androidSignature + jvmSignature
failWithoutSignatures = false

// Android API 21 doesn't have Boolean.hashCode() (etc.) but the Android SDK will desugar these.
// https://r8.googlesource.com/r8/+/516a6684f134d06eff08080e7ef7129517071817
ignore(
"java.lang.Boolean",
"java.lang.Integer",
"java.lang.Long",
"java.lang.Short",
)
}

// Default to only published modules
Expand Down
13 changes: 1 addition & 12 deletions okhttp-tls/src/main/kotlin/okhttp3/tls/internal/der/AnyValue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,4 @@ internal data class AnyValue(
var constructed: Boolean = false,
var length: Long = -1L,
val bytes: ByteString,
) {
// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + tagClass
result = 31 * result + tag.toInt()
result = 31 * result + (if (constructed) 0 else 1)
result = 31 * result + length.toInt()
result = 31 * result + bytes.hashCode()
return result
}
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -117,19 +117,6 @@ internal data class BasicDerAdapter<T>(
*/
fun asTypeHint(): BasicDerAdapter<T> = copy(typeHint = true)

// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + name.hashCode()
result = 31 * result + tagClass
result = 31 * result + tag.toInt()
result = 31 * result + codec.hashCode()
result = 31 * result + (if (isOptional) 1 else 0)
result = 31 * result + defaultValue.hashCode()
result = 31 * result + (if (typeHint) 1 else 0)
return result
}

override fun toString(): String = "$name [$tagClass/$tag]"

/** Reads and writes values without knowledge of the enclosing tag, length, or defaults. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,4 @@ internal data class BitString(
val byteString: ByteString,
/** 0-7 unused bits in the last byte. */
val unusedBitsCount: Int,
) {
// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + byteString.hashCode()
result = 31 * result + unusedBitsCount
return result
}
}
)
21 changes: 2 additions & 19 deletions okhttp-tls/src/main/kotlin/okhttp3/tls/internal/der/Certificate.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,7 @@ internal data class AttributeTypeAndValue(
internal data class Validity(
val notBefore: Long,
val notAfter: Long,
) {
// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + notBefore.toInt()
result = 31 * result + notAfter.toInt()
return result
}
}
)

internal data class SubjectPublicKeyInfo(
val algorithm: AlgorithmIdentifier,
Expand Down Expand Up @@ -184,13 +176,4 @@ internal data class PrivateKeyInfo(
val version: Long,
val algorithmIdentifier: AlgorithmIdentifier,
val privateKey: ByteString,
) {
// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + version.toInt()
result = 31 * result + algorithmIdentifier.hashCode()
result = 31 * result + privateKey.hashCode()
return result
}
}
)
10 changes: 0 additions & 10 deletions okhttp-tls/src/main/kotlin/okhttp3/tls/internal/der/DerHeader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@ internal data class DerHeader(
val isEndOfData: Boolean
get() = tagClass == TAG_CLASS_UNIVERSAL && tag == TAG_END_OF_CONTENTS

// Avoid Long.hashCode(long) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + tagClass
result = 31 * result + tag.toInt()
result = 31 * result + (if (constructed) 0 else 1)
result = 31 * result + length.toInt()
return result
}

override fun toString(): String = "$tagClass/$tag"

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@ data class DnsMessage(
val responseCode: Int
get() = (flags and 0b0000_0000_0000_1111)

// Avoid Short.hashCode(short) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + id
result = 31 * result + flags
result = 31 * result + questions.hashCode()
result = 31 * result + answers.hashCode()
result = 31 * result + authorityRecords.hashCode()
result = 31 * result + additionalRecords.hashCode()
return result
}

companion object {
fun query(
hostname: String,
Expand Down Expand Up @@ -74,16 +62,7 @@ data class Question(
val name: String,
val type: Int,
val `class`: Int = CLASS_IN,
) {
// Avoid Short.hashCode(short) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + name.hashCode()
result = 31 * result + type
result = 31 * result + `class`
return result
}
}
)

sealed interface ResourceRecord {
val name: String
Expand All @@ -93,16 +72,7 @@ sealed interface ResourceRecord {
override val name: String,
override val timeToLive: Int,
val address: InetAddress,
) : ResourceRecord {
// Avoid Int.hashCode(int) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + name.hashCode()
result = 31 * result + timeToLive
result = 31 * result + address.hashCode()
return result
}
}
) : ResourceRecord

data class Https(
override val name: String,
Expand All @@ -113,21 +83,7 @@ sealed interface ResourceRecord {
var port: Int = 443,
val ipAddressHints: List<InetAddress> = listOf(),
val echConfigList: ByteString? = null,
) : ResourceRecord {
// Avoid Int.hashCode(int) which isn't available on Android 5.
override fun hashCode(): Int {
var result = 0
result = 31 * result + name.hashCode()
result = 31 * result + timeToLive
result = 31 * result + priority
result = 31 * result + targetName.hashCode()
result = 31 * result + alpnIds.hashCode()
result = 31 * result + port
result = 31 * result + ipAddressHints.hashCode()
result = 31 * result + echConfigList.hashCode()
return result
}
}
) : ResourceRecord
}

/** https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4 */
Expand Down
Loading