Java API: accept Iterable<? extends T> for collection parameters
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Lĩnh vực
- api, backend-api-design
Hướng nghiên cứu
Start with the candidate API declarations linked in the issue, then read the suggested PR breakdown and the Java tests for the affected methods. Pick one coherent group, such as the HttpHeader or SocketOption signatures, and add Java coverage that passes a collection of a subtype; run the relevant module tests and MiMa check. Done means the selected parameters accept subtype collections and the MiMa check passes.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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). The scaladslHttpRequest/HttpResponseoverrides need to change to match. -
RouteDirectives.complete(..., headers, ...)overloads (RouteDirectives.scala) -
Marshaller.entityToResponse/entityToOKResponse(Marshaller.scala)
Rejection and related
-
RouteResults.rejected(RouteResult.scala) -
Rejections.unsatisfiableRange:ByteRangehas subtypesSlice/FromOffset/Suffix(Rejections.scala) -
Rejections.unsupportedRequestContentType:MediaTypehas subtypesBinary/NonBinary(Rejections.scala)
SocketOption
-
ClientConnectionSettings.withSocketOptions(ClientConnectionSettings.scala) -
ServerSettings.withSocketOptions(ServerSettings.scala)
WebSocket handlers: Java sees Flow / Source / Sink / FlowShape as invariant, so a Flow<Message, TextMessage, NotUsed> (what Flow.of(Message.class).map(m -> TextMessage.create(...)) infers) or a Source<TextMessage, ?> cannot be passed. Our own docs and tests work around this with Arrays.<Message>asList(...) and (Message) TextMessage.create(...) casts. The fix is Flow[? >: Message, ? <: Message, T], FlowShape[? >: Message, ? <: Message], SinkShape[? >: Message] and SourceShape[? <: Message].
-
WebSocketDirectives.handleWebSocketMessages*(6 overloads) (WebSocketDirectives.scala) -
Http.singleWebSocketRequest(3 overloads) (Http.scala) -
WebSocket.handleWebSocketRequestWith(WebSocket.scala) -
WebSocketUpgrade.handleMessagesWith(9 overloads; implementers would need to update their overrides) (WebSocketUpgrade.scala) - testkit
WSTestRequestBuilding.WS(2 overloads) (WSTestRequestBuilding.scala)
Smaller items
-
RouteDirectives.completeOKWithFuture(CompletionStage<RequestEntity>):entity.toStrict(...)returnsCompletionStage<HttpEntity.Strict>, which cannot be passed. UseCompletionStage<? extends RequestEntity>.completeWithFuture(CompletionStage<HttpResponse>)andcompleteWithFutureStatus(CompletionStage<StatusCode>)could change too, for consistency (RouteDirectives.scala) -
JsonEntityStreamingSupport/CsvEntityStreamingSupport.withFramingRendererFlow(Flow<ByteString, ByteString, NotUsed>): the materialized type is fixed toNotUsed, so a flow that materializes anything else is rejected. It should be?(EntityStreamingSupport.scala) -
Rejections.unsupportedRequestContentType(..., Optional<ContentType>):ContentTypehas subtypes (WithCharset,Binary, ...), so useOptional<? extends ContentType>(Rejections.scala)
Out of scope
- Final or effectively final element types (
String,Pair<String, String>, theCoderenum,HttpMethod, javadslHttpEncoding) - 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 Function/Supplier/BiFunctionparameters (e.g.Supplier<Route>inner routes, request handler functions): Java infers lambda and method-reference types from the parameter, so wildcards only help callers holding pre-typed function variables, at the cost of hundreds of signature changesMarshaller/Unmarshallerparameters: they are paired with a method type parameter (complete[T](value: T, m: Marshaller[T, RequestEntity])), so Java inference already finds a fitting type
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.
Suggested PRs
HttpHeader(#1379):HttpMessage.addHeaders/withHeaders(with the scaladslHttpRequest/HttpResponseoverrides), theRouteDirectives.completeoverloads, andMarshaller.entityToResponse/entityToOKResponse. This one matters most, because it is the same API asTrailerin #1374.- Rejections (#1380):
RouteResults.rejected,Rejections.unsatisfiableRangeandRejections.unsupportedRequestContentType. #1380 also covers theOptional<ContentType>parameter ofunsupportedRequestContentTypefrom "Smaller items". SocketOption(#1381):withSocketOptionsonClientConnectionSettingsandServerSettings. This is the smallest change and could go into either of the PRs above.- WebSocket handlers (#1382): all the
Messageflow / source / sink parameters above, with a Java test that passes aFlow<Message, TextMessage, NotUsed>and aSource<TextMessage, NotUsed>. #1382 also removes the docs and test workarounds (Arrays.<Message>asList,(Message)casts). - Smaller items (#1384):
completeOKWithFuture(and the siblingcompleteWith*Future*methods) andwithFramingRendererFlow. TheunsupportedRequestContentTypeitem is in #1380.
Also: #1383 adds tests for the Trailer java.lang.Iterable overloads from #1374 with non-List Iterables.
- Ngôn ngữ chính
- Scala
- Star
- 196
- Fork
- 57
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 53
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của apache/pekko-http
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 45/100
apache/pekko-http#1273 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
HTTP/2 client ALPN fallback needs a handshake-complete signal that the TLS stage does not emitĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/pekko-http#1249 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
apache/pekko-http#1248 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
apache/pekko-http#1180 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
apache/pekko-http#1112 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của apache/pekko-http
Issue tương tự
-
area:build priority:P2 status:backlog
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
KD5UJC-XYZ/scarab#648 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
lichess-org/lila#22324 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
canton-network/splice#8142 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Users who join a new meeting at the same moment: one sometimes gets "Ops, something went wrong" because bbb-web drops their registration (race on `Meeting.userCustomData`)Có thể đã có người làm @antobinary đã nhận 1 ngày trước. Đang mởmodule: core
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bigbluebutton/bigbluebutton#26318 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày