RFR: 8297778: Modernize and improve module jdk.sctp [v5]
Sergey Tsypanov
stsypanov at openjdk.org
Thu Dec 1 10:09:35 UTC 2022
On Wed, 30 Nov 2022 18:34:15 GMT, Per Minborg <pminborg at openjdk.org> wrote:
>> This PR proposes a variety of modernisations to the `jdk.sctp` module.
>>
>> During the fix of https://bugs.openjdk.org/browse/JDK-8296024, several improvement areas were identified including:
>>
>> * Replacing duplicate code segments
>> * Making certain fields final
>> * Using enhanced switch
>> * Using records
>> * Fixing typos
>> * Marking fields participating in serialisation with `@Serial`
>> * Modernizing toString() implementations
>> * Using pattern matching
>> * Using diamond operators
>
> Per Minborg has updated the pull request incrementally with one additional commit since the last revision:
>
> Minor updates
Btw, the same issue with volatile is present in `SctpMultiChannelImpl` and `SctpServerChannelImpl` as well, so you could have a look into them.
src/jdk.sctp/unix/classes/sun/nio/ch/sctp/ResultContainer.java line 124:
> 122: case PEER_ADDRESS_CHANGED -> sb.append("PEER ADDRESS CHANGE");
> 123: case SHUTDOWN -> sb.append("SHUTDOWN");
> 124: default -> sb.append("Unknown result type");
`->` is misaligned here, I think one more whitespace before it would make it look better
src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpChannelImpl.java line 1085:
> 1083: IOUtil.load(); /* loads nio & net native libraries */
> 1084: AccessController.doPrivileged(
> 1085: new java.security.PrivilegedAction<>() {
I think we can import `java.security.PrivilegedAction` instead of using its full name
src/jdk.sctp/unix/classes/sun/nio/ch/sctp/SctpMultiChannelImpl.java line 117:
> 115: /* If an association has been shutdown mark it for removal after
> 116: * the user handler has been invoked */
> 117: private final ThreadLocal<Association> associationToRemove = new ThreadLocal<>();
Nice!
-------------
PR: https://git.openjdk.org/jdk/pull/11418
More information about the net-dev
mailing list