sonar 대응
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
@Controller
|
||||
public class ApiClientController {
|
||||
@@ -26,13 +27,9 @@ public class ApiClientController {
|
||||
|
||||
@PostMapping("/mgmt/api/test.do")
|
||||
@ResponseBody
|
||||
public ApiResponse handleApiRequest(@RequestBody ApiRequestDTO request) {
|
||||
public ApiResponse handleApiRequest(@RequestBody ApiRequestDTO request) throws InterruptedException, ExecutionException {
|
||||
|
||||
try {
|
||||
return nettyApiClient.handleRequest(request).get();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return nettyApiClient.handleRequest(request).get();
|
||||
}
|
||||
|
||||
@GetMapping("/mgmt/api_tester.do")
|
||||
|
||||
@@ -49,15 +49,11 @@ public class NettyApiClient {
|
||||
.option(ChannelOption.TCP_NODELAY, true)
|
||||
.handler(new ChannelInitializer<Channel>() {
|
||||
@Override
|
||||
public void initChannel(Channel ch) {
|
||||
public void initChannel(Channel ch) throws SSLException {
|
||||
if (server.getScheme().equalsIgnoreCase("https")) {
|
||||
try {
|
||||
final SslContext sslCtx = SslContextBuilder.forClient()
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
|
||||
ch.pipeline().addLast(sslCtx.newHandler(ch.alloc(), host, port));// Add SSL handler
|
||||
} catch (SSLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
final SslContext sslCtx = SslContextBuilder.forClient()
|
||||
.trustManager(InsecureTrustManagerFactory.INSTANCE).build();
|
||||
ch.pipeline().addLast(sslCtx.newHandler(ch.alloc(), host, port));// Add SSL handler
|
||||
}
|
||||
|
||||
ch.pipeline().addLast(new HttpClientCodec());
|
||||
@@ -91,7 +87,7 @@ public class NettyApiClient {
|
||||
if (!apiRequest.getHeaders().isEmpty()) {
|
||||
HttpHeaders customHeaders = new DefaultHttpHeaders();
|
||||
apiRequest.getHeaders().stream().filter(ApiRequestKeyValueDTO::isEnabled).forEach(header -> {
|
||||
if(StringUtils.isNotEmpty(header.getKey()) && StringUtils.isNotEmpty(header.getValue())){
|
||||
if (StringUtils.isNotEmpty(header.getKey()) && StringUtils.isNotEmpty(header.getValue())) {
|
||||
customHeaders.set(header.getKey(), header.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user