Skip to content

Commit

Permalink
Update locking mechanism in pekko server
Browse files Browse the repository at this point in the history
  • Loading branch information
IshikaDawda committed Nov 26, 2024
1 parent 160ab1a commit 5225ffd
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,28 @@ public class PekkoCoreUtils {

private static boolean isServletLockAcquired() {
try {
return GenericHelper.isLockAcquired(NR_SEC_CUSTOM_ATTRIB_HTTP_REQ);
return GenericHelper.isLockAcquired(getNrSecCustomAttribHttpReq());
} catch (Throwable ignored) {}
return false;
}

private static void releaseServletLock() {
try {
GenericHelper.releaseLock(NR_SEC_CUSTOM_ATTRIB_HTTP_REQ);
GenericHelper.releaseLock(getNrSecCustomAttribHttpReq());
} catch (Throwable ignored){}
}

public static boolean acquireServletLockIfPossible() {
try {
return GenericHelper.acquireLockIfPossible(NR_SEC_CUSTOM_ATTRIB_HTTP_REQ);
return GenericHelper.acquireLockIfPossible(getNrSecCustomAttribHttpReq());
} catch (Throwable ignored){}
return false;
}

private static String getNrSecCustomAttribHttpReq() {
return NR_SEC_CUSTOM_ATTRIB_HTTP_REQ + Thread.currentThread().getId();
}

public static void postProcessHttpRequest(Boolean isServletLockAcquired, StringBuilder responseBody, String contentType, int responseCode, String className, String methodName, Token token) {
try {
token.linkAndExpire();
Expand Down Expand Up @@ -123,7 +127,6 @@ public static void preProcessHttpRequest(Boolean isServletLockAcquired, HttpRequ
if (queryString != null && !queryString.trim().isEmpty()) {
securityRequest.setUrl(securityRequest.getUrl() + QUESTION_MARK + queryString);
}
System.out.println("content-type : " + request.entity().getContentType());

securityRequest.setContentType(request.entity().getContentType().toString());

Expand All @@ -144,10 +147,8 @@ public static void preProcessHttpRequest(Boolean isServletLockAcquired, HttpRequ
private static String getProtocol(String value) {
if(StringUtils.containsIgnoreCase(value, "https")){
return "https";
} else if (StringUtils.containsIgnoreCase(value, "http")) {
return "http";
} else {
return value;
return "http";
}
}

Expand Down

0 comments on commit 5225ffd

Please sign in to comment.