File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
src/main/java/tech/stackable/druid/opaauthorizer Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -24,10 +24,12 @@ public class OpaAuthorizer implements Authorizer {
2424 private static final Logger LOG = new Logger (OpaAuthorizer .class );
2525 private final String opaUri ;
2626 private final ObjectMapper objectMapper ;
27+ private final HttpClient httpClient ;
2728
2829 @ JsonCreator
2930 public OpaAuthorizer (@ JsonProperty ("name" ) String name , @ JsonProperty ("opaUri" ) String opaUri ) {
3031 this .opaUri = opaUri ;
32+ this .httpClient = HttpClient .newHttpClient ();
3133 objectMapper =
3234 new ObjectMapper ()
3335 // https://github.com/stackabletech/druid-opa-authorizer/issues/72
@@ -53,8 +55,7 @@ public Access authorize(
5355 return new Access (false , "Failed to create the OPA request JSON: " + e );
5456 }
5557
56- LOG .trace ("Creating HTTP Client and executing post." );
57- var client = HttpClient .newHttpClient ();
58+ LOG .trace ("Executing post." );
5859 try {
5960 var request =
6061 HttpRequest .newBuilder ()
@@ -63,7 +64,7 @@ public Access authorize(
6364 .POST (HttpRequest .BodyPublishers .ofString (msgJson ))
6465 .build ();
6566
66- var response = client .send (request , HttpResponse .BodyHandlers .ofString ());
67+ var response = httpClient .send (request , HttpResponse .BodyHandlers .ofString ());
6768
6869 LOG .debug ("OPA Response code: %s - %s" , response .statusCode (), response .body ());
6970 LOG .trace ("Parsing OPA response." );
You can’t perform that action at this time.
0 commit comments