Skip to content

Commit 866b39c

Browse files
committed
Made fields in request and response capture filters volatile or final as appropriate, since they may be modified by multiple threads
1 parent 0a3e6ef commit 866b39c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/ClientRequestCaptureFilter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,18 @@ public class ClientRequestCaptureFilter extends HttpFiltersAdapter {
2626
* Populated by clientToProxyRequest() when processing the HttpRequest object. Unlike originalRequest,
2727
* this represents the "real" request that is being sent to the server, including headers.
2828
*/
29-
private HttpRequest httpRequest;
29+
private volatile HttpRequest httpRequest;
3030

3131
/**
3232
* Populated by clientToProxyRequest() when processing the HttpContent objects. If the request is chunked,
3333
* it will be populated across multiple calls to clientToProxyRequest().
3434
*/
35-
private ByteArrayOutputStream requestContents = new ByteArrayOutputStream();
35+
private final ByteArrayOutputStream requestContents = new ByteArrayOutputStream();
3636

3737
/**
3838
* Populated by clientToProxyRequest() when processing the LastHttpContent.
3939
*/
40-
private HttpHeaders trailingHeaders;
40+
private volatile HttpHeaders trailingHeaders;
4141

4242
public ClientRequestCaptureFilter(HttpRequest originalRequest) {
4343
super(originalRequest);

browsermob-core-littleproxy/src/main/java/net/lightbody/bmp/filters/ServerResponseCaptureFilter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class ServerResponseCaptureFilter extends HttpFiltersAdapter {
2929
/**
3030
* Populated by serverToProxyResponse() when processing the HttpResponse object
3131
*/
32-
private HttpResponse httpResponse;
32+
private volatile HttpResponse httpResponse;
3333

3434
/**
3535
* Populated by serverToProxyResponse() as it receives HttpContent responses. If the response is chunked, it will
@@ -41,27 +41,27 @@ public class ServerResponseCaptureFilter extends HttpFiltersAdapter {
4141
* Populated when processing the LastHttpContent. If the response is compressed and decompression is requested,
4242
* this contains the entire decompressed response. Otherwise it contains the raw response.
4343
*/
44-
private byte[] fullResponseContents;
44+
private volatile byte[] fullResponseContents;
4545

4646
/**
4747
* Populated by serverToProxyResponse() when it processes the LastHttpContent object.
4848
*/
49-
private HttpHeaders trailingHeaders;
49+
private volatile HttpHeaders trailingHeaders;
5050

5151
/**
5252
* Set to true when processing the LastHttpContent if the server indicates there is a content encoding.
5353
*/
54-
private boolean responseCompressed;
54+
private volatile boolean responseCompressed;
5555

5656
/**
5757
* Set to true when processing the LastHttpContent if decompression was requested and successful.
5858
*/
59-
private boolean decompressionSuccessful;
59+
private volatile boolean decompressionSuccessful;
6060

6161
/**
6262
* Populated when processing the LastHttpContent.
6363
*/
64-
private String contentEncoding;
64+
private volatile String contentEncoding;
6565

6666
/**
6767
* User option indicating compressed content should be uncompressed.

0 commit comments

Comments
 (0)