RFR: 8310978: JFR events SocketReadEvent/SocketWriteEvent for Socket adaptor ops [v2]

Alan Bateman alanb at openjdk.org
Tue Oct 24 08:15:38 UTC 2023


On Mon, 23 Oct 2023 22:35:55 GMT, Tim Prinzing <tprinzing at openjdk.org> wrote:

>> Added jar event support to socket adapters.
>> 
>> Added the test jdk/jfr/event/io/TestSocketAdapterEvents.java
>
> Tim Prinzing has updated the pull request incrementally with one additional commit since the last revision:
> 
>   requested change to location of socket adaptor event logic
>   
>   bring back event offer semantics where it was fine.

test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java line 68:

> 66:     public void test() throws Throwable {
> 67:         try (Recording recording = new Recording()) {
> 68:             try (ServerSocketChannel ss = ServerSocketChannel.open()) {

Did you mean to name a ServerSocketChannel "ss", other tests use "ssc".

test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java line 74:

> 72: 
> 73:                 ss.socket().setReuseAddress(true);
> 74:                 ss.socket().bind(null);

Tests usually bind to the loopback address to reduce interference from other programs in the environment. Also ServerSocketChannel defines the bind method so you can do this:


InetAddress lb = InetAddress.getLoopbackAddress();
ssc.bind(new InetSocketAddress(lb, 0));

test/jdk/jdk/jfr/event/io/TestSocketAdapterEvents.java line 103:

> 101:                 readerThread.start();
> 102: 
> 103:                 try (SocketChannel sc = SocketChannel.open(ss.socket().getLocalSocketAddress()); Socket s = sc.socket(); OutputStream os = s.getOutputStream()) {

If you put a line break after each ; then it would be easier to read. Also you can use ssc.getLocalAddress().

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/16251#discussion_r1369775585
PR Review Comment: https://git.openjdk.org/jdk/pull/16251#discussion_r1369777836
PR Review Comment: https://git.openjdk.org/jdk/pull/16251#discussion_r1369779900


More information about the hotspot-jfr-dev mailing list