Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Pranav-b-7 committed Feb 4, 2021
1 parent c1d5eec commit 27c538b
Showing 1 changed file with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import com.netflix.spinnaker.gate.services.internal.OpsmxVisibilityService
import groovy.util.logging.Slf4j
import io.swagger.annotations.ApiOperation
import okhttp3.OkHttpClient
import okio.ByteString
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression
import org.springframework.http.HttpHeaders
Expand Down Expand Up @@ -95,20 +96,15 @@ class OpsmxVisibilityController {
response.getHeaders().forEach({ header ->
headers.add(header.getName(), header.getValue())
})

inputStream = response.getBody().in()
//BufferedReader br = null
StringBuilder sb = new StringBuilder()
String line
BufferedReader br = new BufferedReader(new InputStreamReader(inputStream))
while ((line = br.readLine()) != null) {
sb.append(line)
sb.append('\n')
}
String length = Long.toString(response.body.length())
Integer byteCount = Integer.parseInt(length)
String responseBody = ByteString.read(inputStream, byteCount).utf8()

//inputStream = response.getBody().in()
//String responseBody = new String(IOUtils.toByteArray(inputStream))
//ApprovalGateTriggerResponseModel responseBody = response.getBody().asType(ApprovalGateTriggerResponseModel.class)
String responseBody = sb.toString()

return new ResponseEntity(responseBody, headers, HttpStatus.valueOf(response.getStatus()))
} finally{
if (inputStream!=null){
Expand Down

0 comments on commit 27c538b

Please sign in to comment.