[#13251] - textElement markup="html" multithreading bug

Category:
Bug report
Priority:
Normal
Status:
Acknowledged
Project: Severity:
Minor
Resolution:
Open
Component: Reproducibility:
Sometimes
Assigned to:
0

Hello,

I noticed some random differences using textElement markup="html" in a multi-threaded environment, mostly disappearing text, but also sometimes an extra newline.

After a bit of digging in the code, I think the problem lies in the class JEditorPaneHtmlMarkupProcessor when using a JEditorPane for HTML parsing (which is a Swing component). Below is a test that will fail quite often (but not at every run). I put an assert() just after JEditorPanel use to check the number of elements and it failed.

public class HtmlMultithreadingTest {

public static class HtmlTask implements Runnable {

@Override
public void run() {
JEditorPaneHtmlMarkupProcessor instance = JEditorPaneHtmlMarkupProcessor.getInstance();
String result = instance.convert("<p>Vestibulum ante</p><p>ipsum primis</p>");
Assert.assertEquals("Vestibulum ante\nipsum primis", result);
}
}

@Test
public void go() throws InterruptedException, ExecutionException {

ExecutorService executorService = Executors.newFixedThreadPool(8);
ArrayList<Future<?>> futures = new ArrayList<>();
for(int i = 0; i < 100000; i++) {
Future<?> submit = executorService.submit(new HtmlTask());
futures.add(submit);
}
for(Future<?> f: futures) {
f.get();
}
executorService.shutdown();
executorService.awaitTermination(1, TimeUnit.DAYS);
}
}

v6.12.2
peni18's picture
2
Joined: Nov 23 2020 - 3:04am
Last seen: 1 month 3 weeks ago

1 Comment:

#1
  • Status:New» Acknowledged
Feedback