以调试模式收集的对象垃圾

时间:2018-09-26 13:53:55

标签: java spring eclipse junit

我有一个简单的junit测试

@Test
public void validateMoney() throws IOException {

    ObjectMapper mapper = new ObjectMapper();
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
    FileInputStream fileStream = new FileInputStream("src/test/resources/IndividualMoney.json");
    Money money = mapper.readValue(fileStream, Money.class);
    List<Person> people = personService.execute(money);

每当我在Linux上的Java Oxygen上运行debug并尝试访问人员列表时,我都会在获取值时发生com.sun.jdi.objectcollectedexception发生。我读过类似的问题,解决方案之一是在我取消选中步骤操作后取消选中窗口/首选项/调试Show方法的结果,但是结果是相同的

1 个答案:

答案 0 :(得分:0)

您可以使用人员列表(在其中进行调用)以确保其不会被垃圾收集。

If Intersect(Target, Range("I16:I700")) Is Nothing Then Exit Sub
For Each cell In Target
icolor = 0
Select Case cell
    Case Is <= Date: icolor = 3
    Case Is <= Date + 7: icolor = 44
    Case Is <= Date + 14: icolor = 33
    Case Is <= Date + 30: icolor = 4
    Case Is >= Date + 31: icolor = 2
    End Select
    If icolor <> 0 Then cell.Interior.ColorIndex = icolor
    Next cell

现在,List<Person> people = personService.execute(money); people.forEach(System.out::println); 上的调试标志应允许您浏览people.forEach(System.out::println)列表。

这可以解决您的问题吗?