Files
openide/java/java-impl/resources/inspectionDescriptions/SocketResource.html
Leonid Shalupov 40795fe787 IJI-2422: community/java: move resources under resources root
GitOrigin-RevId: 8b2b63fc6db476ca0c2cfe5cadd84db6c4236d0f
2025-02-05 04:43:28 +00:00

31 lines
1.0 KiB
HTML

<html>
<body>
Reports socket resources that are not safely closed. Socket resources reported
by this inspection include <code>java.net.Socket</code>,
<code>java.net.DatagramSocket</code>, and <code>java.net.ServerSocket</code>.
<p>
By default, the inspection assumes that the resources can be closed by any method with
'close' or 'cleanup' in its name.
</p>
<p><b>Example:</b></p>
<pre><code>
byte[] getMessage(ServerSocket socket) throws IOException {
Socket client = socket.accept(); //socket is not closed
return client.getInputStream().readAllBytes();
}
</code></pre>
<!-- tooltip end -->
<p>
Use the following options to configure the inspection:
</p>
<ul>
<li>
Whether a socket is allowed to be opened inside a <code>try</code> block.
This style is less desirable because it is more verbose than opening a resource in front of a <code>try</code> block.
</li>
<li>
Whether the resource can be closed by any method call with the resource passed as argument.
</li>
</ul>
</body>
</html>