I'm looking to automate some testing of calls we make to an external service. I've gotten Browsermob-proxy and selenium to play together nicely. I'd now like to monitor the requests as they occur, however I am receiving a ConcurrentModificationException in line 5 of the below loop:
while (!found) {
har = server.getHar();
HarLog harLog = har.getLog();
List<HarEntry> entries = harLog.getEntries();
for (HarEntry entry : entries) { //Exception occurs on this line
for (HarNameValuePair queryData : entry.getRequest().getQueryString()) {
found = (queryData.getName().compareToIgnoreCase("events") == 0)
&& (queryData.getValue().contains("event5"));
if (found) {
//Do some processing & break out
}
}
}
}
Is this something I should be doing with a HttpRequestInterceptor instead?
A slight modification to the example will allow this code to work:
List<HarEntry> entries = new CopyOnWriteArrayList<HarEntry>(harLog.getEntries());