pjfanning opened a new issue, #1378:
URL: https://github.com/apache/pekko-http/issues/1378

   Several Java API methods take a `java.lang.Iterable<T>` (or the Scala 
equivalent `java.lang.Iterable[T]`) where `T` has subtypes that Java callers 
commonly hold in typed variables. Java generics are invariant, so a caller with 
e.g. a `List<RawHeader>` cannot pass it to a parameter of type 
`Iterable<HttpHeader>` without copying or casting.
   
   Changing these parameters to `Iterable<? extends T>` (`java.lang.Iterable[_ 
<: T]` in Scala) fixes this. The erased signature is unchanged, so this should 
be binary compatible, and existing Java callers keep compiling.
   
   #1374 does this for `Trailer.addHeaders` / `withHeaders`.
   
   ### Candidates
   
   **`HttpHeader`**
   - [ ] `HttpMessage.MessageTransformations.addHeaders` / `withHeaders` 
([HttpMessage.java](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http-core/src/main/java/org/apache/pekko/http/javadsl/model/HttpMessage.java#L139-L142)).
 The scaladsl `HttpRequest` / `HttpResponse` overrides need to change to match.
   - [ ] `RouteDirectives.complete(..., headers, ...)` overloads 
([RouteDirectives.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/RouteDirectives.scala#L120-L183))
   - [ ] `Marshaller.entityToResponse` 
([Marshaller.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http/src/main/scala/org/apache/pekko/http/javadsl/marshalling/Marshaller.scala#L100))
   
   **`Rejection` and related**
   - [ ] `RouteResults.rejected` 
([RouteResult.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http/src/main/scala/org/apache/pekko/http/javadsl/server/RouteResult.scala#L40))
   - [ ] `Rejections.unsatisfiableRange`: `ByteRange` has subtypes `Slice` / 
`FromOffset` / `Suffix` 
([Rejections.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala#L419))
   - [ ] `Rejections.unsupportedRequestContentType`: `MediaType` has subtypes 
`Binary` / `NonBinary` 
([Rejections.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala#L411))
   
   **`SocketOption`**
   - [ ] `ClientConnectionSettings.withSocketOptions` 
([ClientConnectionSettings.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala#L110))
   - [ ] `ServerSettings.withSocketOptions` 
([ServerSettings.scala](https://github.com/apache/pekko-http/blob/33494d7aa91f9abab91fc7ef17f999684cc86d70/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala#L87))
   
   ### Out of scope
   - Final or effectively final element types (`String`, `Pair<String, 
String>`, the `Coder` enum, `HttpMethod`, javadsl `HttpEncoding`)
   - Return types / getters, where a wildcard makes the result harder to use
   - Function inputs such as `Function<List<String>, Route>`, where the value 
flows to the caller
   
   Each change should come with a Java test that passes a collection of a 
subtype (e.g. `List<RawHeader>`), and the MiMa check should still pass.
   


-- 
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