Skip to content

Commit

Permalink
Steps to avoid potential leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
henrietteharmse committed Oct 18, 2023
1 parent 4d08185 commit ee62657
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ public QueryResponse runSolrQuery(OlsSolrQuery query, Pageable pageable) {

public QueryResponse runSolrQuery(SolrQuery query, Pageable pageable) {

if(pageable != null) {
query.setStart((int)pageable.getOffset());
query.setRows(pageable.getPageSize());
}
if(pageable != null) {
query.setStart((int)pageable.getOffset());
query.setRows(pageable.getPageSize());
}

System.out.println("solr query: " + query.toQueryString());
System.out.println("solr host: " + host);
Expand All @@ -116,17 +116,18 @@ public QueryResponse runSolrQuery(SolrQuery query, Pageable pageable) {
QueryResponse qr = null;
try {
qr = mySolrClient.query(query);
System.out.println("solr query had " + qr.getResults().getNumFound() + " result(s)");
} catch (SolrServerException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
try {
mySolrClient.close();
} catch (IOException ioe){
System.out.println("Failed to close Solr client:" + ioe.getMessage());
}
}

System.out.println("solr query had " + qr.getResults().getNumFound() + " result(s)");

return qr;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public List<Map<String,Object>> rawQuery(String query) {

Result result = session.run(query);

session.close();

return result.stream().map(r -> r.asMap()).collect(Collectors.toList());
}

Expand All @@ -68,6 +70,8 @@ public List<JsonElement> query(String query, String resVar) {

Result result = session.run(query);

session.close();

return result.list().stream()
.map(r -> r.get(resVar).get("_json").asString())
.map(JsonParser::parseString)
Expand All @@ -78,7 +82,6 @@ public Page<JsonElement> queryPaginated(String query, String resVar, String coun

Session session = getSession();


String sort = "";
String queryToRun;

Expand Down Expand Up @@ -115,6 +118,7 @@ public Page<JsonElement> queryPaginated(String query, String resVar, String coun
Result countResult = session.run(countQuery, parameters);
System.out.println("Neo4j run paginated count: " + timer2.stop());

session.close();
Record countRecord = countResult.single();
int count = countRecord.get(0).asInt();

Expand All @@ -139,6 +143,7 @@ public JsonElement queryOne(String query, String resVar, Value parameters) {
Result result = session.run(query, parameters);
System.out.println("Neo4j run query " + query + ": " + timer.stop());

session.close();
Value v = null;

try {
Expand Down
4 changes: 4 additions & 0 deletions k8chart/ols4/templates/ols4-backend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,9 @@ spec:
- name: SERVER_SERVLET_CONTEXT_PATH
value: /ols4
- name: JAVA_OPTIONS
value: "-XX:InitialRAMPercentage=58.0 -XX:MinRAMPercentage=58.0 -XX:MaxRAMPercentage=78.0"
- name: JAVA_OPTS
value: "-XX:InitialRAMPercentage=59.0 -XX:MinRAMPercentage=59.0 -XX:MaxRAMPercentage=79.0"
- name: JDK_JAVA_OPTIONS
value: "-XX:InitialRAMPercentage=60.0 -XX:MinRAMPercentage=60.0 -XX:MaxRAMPercentage=80.0"

0 comments on commit ee62657

Please sign in to comment.