Skip to content

Commit 834b79e

Browse files
committed
aadarsh-st/SK-2521:Fixed copilot comments
1 parent 84cb6df commit 834b79e

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/main/java/com/skyflow/utils/HttpUtility.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,18 @@ public static String sendRequest(String method, URL url, JsonObject params, Map<
7676

7777
int httpCode = connection.getResponseCode();
7878
String requestID = connection.getHeaderField("x-request-id");
79-
HttpUtility.requestID = requestID.split(",")[0];
79+
if (requestID != null) {
80+
HttpUtility.requestID = requestID.split(",")[0];
81+
} else {
82+
HttpUtility.requestID = "Internal-SDK-" + UUID.randomUUID();
83+
}
8084
Map<String, List<String>> responseHeaders = connection.getHeaderFields();
8185
Reader streamReader;
8286
if (httpCode > 299) {
8387
if (connection.getErrorStream() != null)
8488
streamReader = new InputStreamReader(connection.getErrorStream());
8589
else {
86-
String description = appendRequestId("replace with description", requestID);
90+
String description = appendRequestId("Server returned error", requestID);
8791
throw new SkyflowException(description);
8892
}
8993
} else {

src/main/java/com/skyflow/utils/Utils.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public static String constructConnectionURL(ConnectionConfig config, InvokeConne
113113
String key = entry.getKey();
114114
String value = entry.getValue();
115115
try {
116-
String encodedValue = URLEncoder.encode(value, StandardCharsets.UTF_8.toString());
116+
String encodedValue = URLEncoder.encode(value, StandardCharsets.UTF_8.name());
117117
filledURL = new StringBuilder(filledURL.toString().replace(String.format("{%s}", key), encodedValue));
118118
} catch (Exception e) {
119119
filledURL = new StringBuilder(filledURL.toString().replace(String.format("{%s}", key), value));
@@ -127,8 +127,8 @@ public static String constructConnectionURL(ConnectionConfig config, InvokeConne
127127
String key = entry.getKey();
128128
String value = entry.getValue();
129129
try {
130-
String encodedKey = URLEncoder.encode(key, StandardCharsets.UTF_8.toString());
131-
String encodedValue = URLEncoder.encode(value, StandardCharsets.UTF_8.toString());
130+
String encodedKey = URLEncoder.encode(key, StandardCharsets.UTF_8.name());
131+
String encodedValue = URLEncoder.encode(value, StandardCharsets.UTF_8.name());
132132
filledURL.append(encodedKey).append("=").append(encodedValue).append("&");
133133
} catch (Exception e) {
134134
filledURL.append(key).append("=").append(value).append("&");

src/main/java/com/skyflow/vault/controller/ConnectionController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ public InvokeConnectionResponse invoke(InvokeConnectionRequest invokeConnectionR
9292
Object data = response;
9393
try {
9494
data = JsonParser.parseString(response).getAsJsonObject();
95-
} catch (Exception ignored) {}
95+
} catch (Exception e) {
96+
LogUtil.printErrorLog(ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.getLog());
97+
}
9698
HashMap<String, String> metadata = new HashMap<>();
9799
metadata.put("requestId", HttpUtility.getRequestID());
98100
connectionResponse = new InvokeConnectionResponse(data, metadata, null);

0 commit comments

Comments
 (0)