1
0
mirror of https://github.com/square/okhttp.git synced 2025-08-08 23:42:08 +03:00

Avoiding direct java.lang usage (#5065)

* i

* i

* i
This commit is contained in:
Yuri Schimke
2019-05-18 11:44:20 +01:00
committed by Jesse Wilson
parent 7337b1d7ac
commit f468cfc7b2
3 changed files with 10 additions and 6 deletions

View File

@@ -241,7 +241,7 @@ class HttpLoggingInterceptor @JvmOverloads constructor(
logger.log("<-- END HTTP (encoded body omitted)")
} else {
val source = responseBody.source()
source.request(java.lang.Long.MAX_VALUE) // Buffer the entire body.
source.request(Long.MAX_VALUE) // Buffer the entire body.
var buffer = source.buffer
var gzippedLength: Long? = null

View File

@@ -246,3 +246,7 @@ fun ServerSocket?.closeQuietly() {
fun isAndroidGetsocknameError(e: AssertionError): Boolean {
return e.cause != null && e.message?.contains("getsockname failed") == true
}
fun Long.toHexString() = java.lang.Long.toHexString(this)
fun Int.toHexString() = Integer.toHexString(this)

View File

@@ -16,6 +16,7 @@
package okhttp3.internal.ws
import okhttp3.internal.and
import okhttp3.internal.toHexString
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_FIN
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV1
import okhttp3.internal.ws.WebSocketProtocol.B0_FLAG_RSV2
@@ -39,7 +40,6 @@ import okio.Buffer
import okio.BufferedSource
import okio.ByteString
import java.io.IOException
import java.lang.Integer.toHexString
import java.net.ProtocolException
import java.util.concurrent.TimeUnit
@@ -152,7 +152,7 @@ internal class WebSocketReader(
frameLength = source.readLong()
if (frameLength < 0) {
throw ProtocolException(
"Frame length 0x${java.lang.Long.toHexString(frameLength)} > 0x7FFFFFFFFFFFFFFF")
"Frame length 0x${frameLength.toHexString()} > 0x7FFFFFFFFFFFFFFF")
}
}
@@ -202,7 +202,7 @@ internal class WebSocketReader(
closed = true
}
else -> {
throw ProtocolException("Unknown control opcode: " + toHexString(opcode))
throw ProtocolException("Unknown control opcode: " + opcode.toHexString())
}
}
}
@@ -211,7 +211,7 @@ internal class WebSocketReader(
private fun readMessageFrame() {
val opcode = this.opcode
if (opcode != OPCODE_TEXT && opcode != OPCODE_BINARY) {
throw ProtocolException("Unknown opcode: ${toHexString(opcode)}")
throw ProtocolException("Unknown opcode: ${opcode.toHexString()}")
}
readMessage()
@@ -260,7 +260,7 @@ internal class WebSocketReader(
readUntilNonControlFrame()
if (opcode != OPCODE_CONTINUATION) {
throw ProtocolException("Expected continuation opcode. Got: ${toHexString(opcode)}")
throw ProtocolException("Expected continuation opcode. Got: ${opcode.toHexString()}")
}
}
}