Ao usar StreamParser.parse(), é descoberto que os links hrefs são duplicados, enquanto que usar Jsoup.parse() retorna o documento esperado. Existe algum motivo pelo qual StreamParser criaria referências adicionais para href?
Esse é o comportamento esperado ao usar um StreamParser?
String s1= "<!DOCTYPE html>\n"
+ "<html>\n"
+ "<head>\n"
+ " <title></title>\n"
+ "</head>\n"
+ "<body>\n"
+ " <a href=\"https://fake.com/:x:/g/gibberishtext\">Some link</a>\n"
+ "</body>\n"
+ "</html>";
StreamParser streamParser = new StreamParser(Parser.htmlParser());
StreamParser parse = streamParser.parse(s1, "");
parse.stream().forEach(System.out::println);
// Saída do StreamParser, Retorna cinco referências para href
<title></title>
<head>
<title></title>
</head>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
<body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
</body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
<body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
</body>
<html>
<head>
<title></title>
</head>
<body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
</body>
</html>
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
</body>
</html>
Enquanto usar Jsoup.parse() retorna o documento esperado
Document parse1 = Jsoup.parse(s1);
System.out.println(parse1.toString());
//Saída do uso do Jsoup 1.19.1
<!doctype html>
<html>
<head>
<title></title>
</head>
<body>
<a href="https://fake.com/:x:/g/gibberishtext">Some link</a>
</body>
</html>
Mais atualizações...
Agora para tornar isso mais interessante...
Se eu chamar Jsoup.parse(s1).stream().forEach(System.out::println), ele retornará um resultado semelhante ao StreamParser.
Por que chamar stream() está causando duplicação?