Skip to content

Commit

Permalink
Merge pull request #3090 from dulanjalidilmi/master-build-fix-2
Browse files Browse the repository at this point in the history
Fix intermittent build failure
  • Loading branch information
dulanjalidilmi authored Jan 26, 2024
2 parents 3d59f47 + a6adce1 commit 0f94def
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,7 @@ protected void reloadSessionCookie() throws Exception {
* @param logLevel - The log-level of synapse-transport-http-wire logger
*/
public void configureHTTPWireLogs(String logLevel) {
String loggerName = "synapse-transport-http-wire";
if (!isManagementApiAvailable) {
Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(DEFAULT_TIMEOUT, TimeUnit.SECONDS).
until(isManagementApiAvailable());
Expand All @@ -1192,15 +1193,40 @@ public void configureHTTPWireLogs(String logLevel) {
+ "logging";

JSONObject payload = new JSONObject();
payload.put("loggerName", "synapse-transport-http-wire");
payload.put("loggerName", loggerName);
payload.put("loggingLevel", logLevel);

client.doPatch(endpoint, headers, payload.toString(), "application/json");
Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).
atMost(DEFAULT_TIMEOUT, TimeUnit.SECONDS).until(isLogsConfigured(endpoint, loggerName, logLevel));
} catch (IOException e) {
throw new SynapseException("Error updating the log-level of synapse-transport-http-wire logger", e);
}
}

private Callable<Boolean> isLogsConfigured(String endpoint, String loggerName, String logLevel) {
return () -> isLogConfigured(endpoint + "?loggerName=" + loggerName, logLevel);
}

private boolean isLogConfigured(String endpoint, String logLevel) {
try {
SimpleHttpClient client = new SimpleHttpClient();
Map<String, String> headers = new HashMap<>();
headers.put("Accept", "application/json");

HttpResponse response = client.doGet(endpoint, headers);
String responsePayload = client.getResponsePayload(response);
if (response.getStatusLine().getStatusCode() != 200) {
return false;
}
JSONObject jsonResponse = new JSONObject(responsePayload);
return jsonResponse.get("level").toString().equals(logLevel);
} catch (IOException e) {
log.error("Error occurred while checking the log level", e);
return false;
}
}

private void copyArtifactToDeploymentDirectory(String sourceArtifactPath, String artifactName,
String deploymentDirectory) throws IOException {
Files.copy(new File(sourceArtifactPath + File.separator + artifactName + ".xml").toPath(),
Expand Down

0 comments on commit 0f94def

Please sign in to comment.