Monitoring Har Files

161 views
Skip to first unread message

Scott

unread,
Feb 8, 2012, 9:41:09 AM2/8/12
to BrowserMob Proxy
I am attempting to monitor some of the traffic coming through the
proxy server to look for a few requests. I have the following loop:

while(!found) {
har = server.getHar();
HarLog harLog = har.getLog();
List <HarEntry> entries = harLog.getEntries();
for (HarEntry entry : entries) {
for(HarNameValuePair queryData :
entry.getRequest().getQueryString()) {
found = "events".equals(queryData.getName()) == 0) &&
(queryData.getValue().contains("event5"));
//Rest ommitted
}
}
}

I'm receiving a ConcurrentModificationException on line 5 of the above
snippet. Is there another way I should be doing this? Should this
perhaps be done with a HttpRequestInterceptor?

Patrick Lightbody

unread,
Feb 8, 2012, 10:49:10 AM2/8/12
to browserm...@googlegroups.com
The interceptor definitely would avoid the problem you're hitting, but we probably should just make the data we give back thread safe. Can you open a bug for this and include a fully reproducible test case?

--
Patrick Lightbody



Scott

unread,
Feb 8, 2012, 11:15:47 AM2/8/12
to BrowserMob Proxy
Created the following issue: https://github.com/webmetrics/browsermob-proxy/issues/39

Please let me know if you need anything else, or would like me to do
some testing of the fix.

Patrick Lightbody

unread,
Feb 8, 2012, 11:17:28 AM2/8/12
to browserm...@googlegroups.com
K. And definitely try using an interceptor as a workaround for now.

--
Patrick Lightbody




Scott

unread,
Feb 8, 2012, 1:14:25 PM2/8/12
to BrowserMob Proxy
I also kept playing. If I change line 5 to:

List<HarEntry> entries = new
CopyOnWriteArrayList<HarEntry>(harLog.getEntries());

I get the results I'd like.

I cloned the repository, and am seeing about implementing a fix as
well, but I am unsure whether or not I can send that patch back
upstream, so before I bite off something like that I am waiting to
hear back from legal.

Damien

unread,
Feb 29, 2012, 10:46:34 AM2/29/12
to BrowserMob Proxy
Has a patch been submitted for this yet?

I was wondering if adding another method like getCurrentLog which
performs the copy and returns an immutable version of the list would
be more appropriate, making the current getter package scope to
signify that it should only be used by the proxy?

I am happy to push the proposed change as it is similar to what I was
considering if it has not been done.

I am seeing a lot of concurrent modification exceptions in my tests
and I would like to resolve this before pushing them into our CI.

Scott

unread,
Feb 29, 2012, 11:06:05 AM2/29/12
to BrowserMob Proxy
I have yet to submit a patch. I'm awaiting word from legal on how to
proceed.

That was the path I was thinking about as well, but if I remember
correctly I still saw some concurrent modification exceptions even
when returning a new List with the current values, but that was many a
few Mondays ago (aka I may have missed something somewhere, I might
have also simply been returning a new list from the getter, and not
rescoping it and adding the new method).

Patrick Lightbody

unread,
Mar 1, 2012, 2:43:53 AM3/1/12
to browserm...@googlegroups.com
I can try to take a stab at this myself, but I need a reproducible test case first.

--
Patrick Lightbody




Scott

unread,
Mar 1, 2012, 9:26:28 AM3/1/12
to BrowserMob Proxy
I placed a test case in the issue I created -- is that not working for
you? I'm able to reproduce a CME every time I use a similar test
locally.

https://github.com/webmetrics/browsermob-proxy/issues/39

Patrick Lightbody

unread,
Mar 10, 2012, 9:33:09 PM3/10/12
to browserm...@googlegroups.com
I just checked in a fix for this and will try to do a release this week.

--
Patrick Lightbody




Reply all
Reply to author
Forward
0 new messages