简体   繁体   English

双 Java Stream 在需要时不会离开

[英]Double Java Stream not leaving when wanted

Here is my problem.这是我的问题。

public LinkedHashSet<Quiz> findAllQuizByCompanyAndCategory(List<QuizCompany> quizList, String quizCategoryId) {
    int i = 1;
    return hibernateQuizJpaRepository
                 .findAllByCategorySetContaining(new HibernateQuizCategory(quizCategoryId))
                 .stream()
                 .filter(current -> quizList.stream()
                 .anyMatch(quiz -> Objects.equals(current.getId(), quiz.getQuizId())))
                 .map(HibernateQuiz::toQuiz)
                 .collect(Collectors.toCollection(LinkedHashSet::new));
 }

As you can see on the screen the quizId and the id are the same on the anymatch.正如您在屏幕上看到的,在 anymatch 中 quizId 和 id 是相同的。 But it will never enter in the map.但它永远不会进入地图。 Does anyone have an idea why?有谁知道为什么?

Removed breakpoints because the issue has been solved删除断点,因为问题已解决

Try to use String.intern on尝试使用 String.intern

    current.getId().intern() 

and

  quiz.getQuizId().intern()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM