pjfanning opened a new pull request, #1381:
URL: https://github.com/apache/pekko-http/pull/1381

   ### Motivation
   Pekko's Java socket option factories return concrete subtypes. For example, 
`TcpSO.keepAlive(true)` returns `Tcp.SO.KeepAlive` and 
`TcpSO.receiveBufferSize(n)` returns `Inet.SO.ReceiveBufferSize`. Java generics 
are invariant, so `settings.withSocketOptions(List.of(TcpSO.keepAlive(true)))` 
does not compile against `withSocketOptions(Iterable<SocketOption>)`. This is 
suggested PR 3 of #1378.
   
   ### Modification
   Widen the parameter to `Iterable<? extends SocketOption>` 
(`java.lang.Iterable[? <: SocketOption]` in Scala) in:
   - javadsl `ServerSettings.withSocketOptions`, plus the scaladsl 
`ServerSettings` override
   - javadsl `ClientConnectionSettings.withSocketOptions`
   
   The implementations convert with `asScala.toList`, which produces a 
covariant Scala `List`, so they need no cast.
   
   MiMa reports `IncompatibleSignatureProblem` for the 3 methods because the 
generic signature changed. The erased JVM signatures are unchanged, so existing 
compiled callers still link and existing Java sources still compile. The 
excludes are in a new `java-iterable-socket-option-wildcard.excludes`. Both 
javadsl settings classes are `@DoNotInherit`, so no user overrides are affected.
   
   No docs change: the methods behave the same, they just accept more argument 
types.
   
   ### Result
   Java callers can pass collections of `SocketOption` subtypes, including what 
the `TcpSO` / `UdpSO` factories return.
   
   ### Tests
   - `sbt "http-core/Test/testOnly 
org.apache.pekko.http.javadsl.settings.ServerSettingsTest 
org.apache.pekko.http.javadsl.settings.ClientConnectionSettingsTest"`: passed 
on Scala 2.13 and 3.3.8
     - new case in each test: `withSocketOptions` with a `List<? extends 
Inet.SocketOption>` built from `TcpSO.keepAlive(true)` and 
`TcpSO.receiveBufferSize(1024)`, then checks `getSocketOptions()` returns the 
same options
     - both new cases fail to compile against the old signatures
   - `sbt http-core/mimaReportBinaryIssues`: passed with the new excludes
   - `http-core/scalafmtCheckAll`, `http-core/Test/javafmtCheck` (JDK 17) and 
`http-core/headerCheckAll`: passed
   
   ### References
   Refs #1378
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to