Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ALS-7778: Fix bottleneck in wildfly #210

Merged
merged 14 commits into from
Nov 4, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ private HashMap<String, Object> prepareRequestMap(ContainerRequestContext reques
Response formatResponse = resourceWebClient.queryFormat(resource.getResourceRSPath(), queryRequest);
if (formatResponse.getStatus() == 200) {
// add the formatted query if available
String formattedQuery = IOUtils.toString((InputStream) formatResponse.getEntity(), "UTF-8");
String formattedQuery = (String) formatResponse.getEntity();
logger.debug("Formatted response: " + formattedQuery);
requestMap.put("formattedQuery", formattedQuery);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void testQuery() throws IOException {
//Should throw an error if credentials missing or wrong
System.out.println("401 URL: " + endpointUrl+"/query" + "|headers: " + headers + "|body: " + body);
HttpResponse response = retrievePostResponse(endpointUrl+"/query", headers, body);
// System.out.println("Test Response: " + IOUtils.toString(response.getEntity().getContent(), "UTF-8"));
// System.out.println("Test Response: " + EntityUtils.toString(response.getEntity().getContent(), "UTF-8"));
assertEquals("Missing credentials should return a 401", 401, response.getStatusLine().getStatusCode());
JsonNode responseMessage = objectMapper.readTree(response.getEntity().getContent());
assertNotNull("Response message should not be null", responseMessage);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public void testQueryResult() throws UnsupportedOperationException, IOException
body = objectMapper.writeValueAsString(queryRequest);
response = retrievePostResponse(irctEndpointUrl+"pic-sure/v1.4/query/"+testQueryResultId+"/result", headers, body);
assertEquals("Correct request should return a 200",200, response.getStatusLine().getStatusCode());
String responseBody = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
String responseBody = EntityUtils.toString(response.getEntity().getContent(), "UTF-8");
assertFalse("Response content should not be empty", responseBody.isEmpty());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public void testResult() throws Exception {
//This should return some kind of result
response = retrievePostResponse(uri, headers, objectMapper.writeValueAsString(resultRequest));
assertEquals("Correct request should return a 200", 200, response.getStatusLine().getStatusCode());
String result = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
String result = EntityUtils.toString(response.getEntity().getContent(), "UTF-8");
assertNotNull("Result should not be null, result");

//Nonexistent resultId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void testStatusIsAccessibleToSystemUser() throws Exception {
get.setHeader(HttpHeaders.AUTHORIZATION, "Bearer "+ jwt);
HttpResponse response = client.execute(get);
assertEquals("Response status code should be 200", 200, response.getStatusLine().getStatusCode());
assertEquals("System status should be RUNNING'", "RUNNING", IOUtils.toString(response.getEntity().getContent(), "UTF-8"));
assertEquals("System status should be RUNNING'", "RUNNING", EntityUtils.toString(response.getEntity().getContent(), "UTF-8"));

}catch(Exception e) {
fail("Exception: " + e.getMessage());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ private static void parseCommandLine(String[] args) throws ParseException, FileN
printHelpAndExit();
}
url = cmd.getOptionValue("p");
users = IOUtils.toString(new FileInputStream(cmd.getOptionValue("u")), "UTF-8");
resources = IOUtils.toString(new FileInputStream(cmd.getOptionValue("r")), "UTF-8");
users = EntityUtils.toString(new FileInputStream(cmd.getOptionValue("u")), "UTF-8");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

resources = EntityUtils.toString(new FileInputStream(cmd.getOptionValue("r")), "UTF-8");
token = cmd.getOptionValue("t");
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import edu.harvard.dbmi.avillach.service.IResourceRS;
import org.apache.http.message.BasicHeader;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -278,7 +279,7 @@ public QueryStatus query(QueryRequest queryJson) {
// If the HTTP Response is a success, then returns an object like so: {"resultId":230464}
//TODO later Add things like duration and expiration
try {
String responseBody = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
JsonNode responseNode = json.readTree(responseBody);

long endtime = new Date().getTime();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;

import edu.harvard.dbmi.avillach.util.exception.ResourceCommunicationException;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -56,7 +57,7 @@ public static HttpResponse retrievePostResponse(String uri, String token) {

public static <T> List<T> readListFromResponse(HttpResponse response, Class<T> expectedElementType) {
try {
String responseBody = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
return json.readValue(responseBody, new TypeReference<List<T>>() {});
} catch (IOException e) {
e.printStackTrace();
Expand All @@ -66,7 +67,7 @@ public static <T> List<T> readListFromResponse(HttpResponse response, Class<T> e

public static <T> List<T> readDataObjectsFromResponse(HttpResponse response, Class<T> expectedElementType) {
try {
String responseBody = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
String responseBody = EntityUtils.toString(response.getEntity(), "UTF-8");
// Get only the data_objects field from the returned structure. Ugly, but has to de- and then re-serialize
JsonNode jn = json.readTree(responseBody);
if (null == jn.get("data_objects")) {
Expand Down

This file was deleted.

Loading
Loading