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

[Bug] FlatMapperIterator should be closed after usage #2280

Closed
1 task done
qwtsc opened this issue Aug 14, 2023 · 2 comments · Fixed by #2281
Closed
1 task done

[Bug] FlatMapperIterator should be closed after usage #2280

qwtsc opened this issue Aug 14, 2023 · 2 comments · Fixed by #2281
Labels
bug Something isn't working

Comments

@qwtsc
Copy link
Contributor

qwtsc commented Aug 14, 2023

Bug Type (问题类型)

others (please edit later)

Before submit

  • 我已经确认现有的 IssuesFAQ 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

Environment (环境信息)

  • SonarQube block issue [java:S2095]

Connections, streams, files, and other classes that implement the Closeable interface or its super-interface, AutoCloseable, needs to be closed after use. Further, that close call must be made in a finally block otherwise an exception could keep the call from being made. Preferably, when class implements AutoCloseable, resource should be created using "try-with-resources" pattern and will be closed automatically.

Failure to properly close resources will result in a resource leak which could bring first the application and then perhaps the box the application is on to their knees.

Expected & Actual behavior (期望与实际表现)

        // Multiple steps, construct first step to iterator
        Iterator<Edge> edges = this.edgesOfVertexWithCount(source, firstStep);
        // Wrap steps to Iterator except last step
        for (int i = 1; i < stepNum - 1; i++) {
            EdgeStep currentStep = steps.get(i);
            edges = new FlatMapperIterator<>(edges, (edge) -> {
                Id target = ((HugeEdge) edge).id().otherVertexId();
                return this.edgesOfVertexWithCount(target, currentStep);
            });
        }

close FlatMapperIterator after usage

Vertex/Edge example (问题点 / 边数据举例)

No response

Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

No response

@qwtsc qwtsc added the bug Something isn't working label Aug 14, 2023
@imbajin
Copy link
Member

imbajin commented Aug 14, 2023

There are indeed some iterators in the current code that have not been finally closed.

U can confirm their lifecycle, if they are indeed legacy and may cause potential impact, you can help submit PR fixes (there should be some places in the class)

@qwtsc
Copy link
Contributor Author

qwtsc commented Aug 14, 2023

There are indeed some iterators in the current code that have not been finally closed.

U can confirm their lifecycle, if they are indeed legacy and may cause potential impact, you can help submit PR fixes (there should be some places in the class)

I have scanned the code, this is only case and u can review the above PR.

imbajin pushed a commit that referenced this issue Aug 29, 2023
close [Bug] FlatMapperIterator should be closed after usage #2280
DanGuge pushed a commit to DanGuge/incubator-hugegraph that referenced this issue Sep 25, 2023
close [Bug] FlatMapperIterator should be closed after usage apache#2280
VGalaxies pushed a commit to VGalaxies/incubator-hugegraph that referenced this issue Nov 10, 2023
close [Bug] FlatMapperIterator should be closed after usage apache#2280
imbajin pushed a commit that referenced this issue Nov 10, 2023
close [Bug] FlatMapperIterator should be closed after usage #2280
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

Successfully merging a pull request may close this issue.

2 participants