@@ -14,7 +14,7 @@ package org.web3j.quorum.enclave.protocol
14
14
15
15
import com.fasterxml.jackson.annotation.JsonInclude
16
16
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
17
- import okhttp3.MediaType
17
+ import okhttp3.MediaType.Companion.toMediaTypeOrNull
18
18
import okhttp3.OkHttpClient
19
19
import okhttp3.Request
20
20
import okhttp3.RequestBody
@@ -28,7 +28,7 @@ class EnclaveService(private val url: String, private val port: Int, private val
28
28
29
29
private val objectMapper = jacksonObjectMapper()
30
30
.setSerializationInclusion(JsonInclude .Include .NON_NULL )
31
- private val JSON_MEDIA_TYPE = MediaType .parse( " application/json; charset=utf-8" )
31
+ private val JSON_MEDIA_TYPE = " application/json; charset=utf-8" .toMediaTypeOrNull( )
32
32
33
33
/* *
34
34
* Send a new raw payload to Enclave
@@ -45,11 +45,11 @@ class EnclaveService(private val url: String, private val port: Int, private val
45
45
val response = client.newCall(buildRequest).execute()
46
46
47
47
if (response.isSuccessful) {
48
- val chunk = response.body() ?.string()
48
+ val chunk = response.body?.string()
49
49
return objectMapper.readValue(chunk, responseType)
50
50
} else {
51
- val statusCode = response.code()
52
- val text = if (response.body() == null ) " N/A" else response.body() ?.string()
51
+ val statusCode = response.code
52
+ val text = if (response.body == null ) " N/A" else response.body?.string()
53
53
54
54
throw EnclaveClientConnectionException (" Invalid response received from enclave: $statusCode $text " )
55
55
}
@@ -65,6 +65,6 @@ class EnclaveService(private val url: String, private val port: Int, private val
65
65
.get()
66
66
.build()
67
67
val response = client.newCall(request).execute()
68
- return response.body() ?.string() ? : " "
68
+ return response.body?.string() ? : " "
69
69
}
70
70
}
0 commit comments