Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the return value object uses Void (java.lang.Void), it will result in an infinite loop. #4

Closed
shanggn opened this issue Nov 22, 2019 · 4 comments
Labels
bug Something isn't working

Comments

@shanggn
Copy link

shanggn commented Nov 22, 2019

When the interface's return value or parameters, property references are self-referential, it will lead to an infinite loop and ultimately cause a memory overflow.
`java.lang.OutOfMemoryError: Java heap space

at java.util.Arrays.copyOf(Arrays.java:3332)
at java.lang.AbstractStringBuilder.ensureCapacityInternal(AbstractStringBuilder.java:124)
at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:448)
at java.lang.StringBuilder.append(StringBuilder.java:136)
at com.power.doc.builder.SourceBuilder.buildJson(SourceBuilder.java:966)
at com.power.doc.builder.SourceBuilder.buildJson(SourceBuilder.java:966)
at com.power.doc.builder.SourceBuilder.buildJson(SourceBuilder.java:966)
at com.power.doc.builder.SourceBuilder.buildJson(SourceBuilder.java:966)`
@netdied
Copy link
Collaborator

netdied commented Nov 22, 2019

Can you provide a specific example? Or try upgrading to version 1.7.5 or above.
能给出你的具体例子么?或者升级到1.7.5以上版本试一下

@shanggn
Copy link
Author

shanggn commented Nov 25, 2019

Sorry, because there are several methods in the same class, I thought the infinite loop was caused by nested objects. After testing each method, it turns out to be caused by a method with a return type of Void object.

不好意思,因为我同一个类里面好几个方法,我看到死循环以为是嵌套对象导致的,实际挨个方法测试下来,是因为一个返回值为Void对象的方法

@GetMapping("test")
public Result<Void> test() {
        return Result.success(null);
}

@shanggn shanggn closed this as completed Nov 25, 2019
@shanggn shanggn changed the title 嵌套对象出现死循环 当返回值对象使用Void(java.lang.Void) 会出现死循环 Nov 25, 2019
@shanggn shanggn reopened this Nov 25, 2019
@netdied
Copy link
Collaborator

netdied commented Nov 25, 2019

Currently, you can directly ignore the Void.
目前你可以直接

 Result test(){
return Result.ok();
}

@shalousun
Copy link
Collaborator

shalousun commented Nov 26, 2019

This bug has been fixed

@shalousun shalousun added the bug Something isn't working label Dec 6, 2020
@shalousun shalousun changed the title 当返回值对象使用Void(java.lang.Void) 会出现死循环 When the return value object uses Void (java.lang.Void), it will result in an infinite loop. May 20, 2024
@TongchengOpenSource TongchengOpenSource deleted a comment from shanggn May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants