You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is just a question. Is it possible to write an arch unit test that verifies that calls for certain methods are always wrapped with try-with-resources?
Stream<User> stream = repository.findAllByCustomQueryAndStream();
//do something with stream
Context: Spring repository methods that return Stream should be wrapped by a try-with-resources block, as suggested by the official docs.
I have tried inspecting the TryCatchBlock object but it does not give me information on what's actually being wrapped, it only contains info on the //do something with stream block and the caught exceptions.
The text was updated successfully, but these errors were encountered:
bfreitastgtg
changed the title
How to verify that a method is wrapped with try-with-resources
How to verify that a method is wrapped with try-with-resources?
Dec 19, 2024
This is just a question. Is it possible to write an arch unit test that verifies that calls for certain methods are always wrapped with try-with-resources?
The method:
Compliant call:
Non-compliant call:
Context: Spring repository methods that return
Stream
should be wrapped by a try-with-resources block, as suggested by the official docs.I have tried inspecting the
TryCatchBlock
object but it does not give me information on what's actually being wrapped, it only contains info on the//do something with stream
block and the caught exceptions.The text was updated successfully, but these errors were encountered: