Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Add wildcard bounds to Java DSL parameters that are needlessly invariant

クローズ
#3,712 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
java, scala
領域
api, backend

調査の方向性

Read the Java DSL signatures for Source, Sink, Flow, SubFlow, SubSource, and FlowWithContext, plus persistence-typed javadsl Effect.persist(events). Start with the Java tests that exercise these parameters and add narrower-typed variables to verify they compile. Done means the listed wildcard bounds are consistent, those tests pass, and mimaReportBinaryIssues stays clean for stream and persistence-typed.

索引モデルが issue の本文から書いたものです。

説明

Java generics are invariant, so several Java DSL parameters reject values that a Java user would reasonably expect to pass, typically a variable whose declared type is a narrower generic (e.g. List<Source<T, NotUsed>> or List<ItemAdded>). Lambdas mostly adapt to the target type; pre-typed variables, fields and method references do not.

Adding wildcard bounds only changes the generic signature, not the erased descriptor, so this should be binary compatible (MiMa clean) and source compatible for existing Java and Scala callers.

Parameters that reject ordinary Java variables
Location Today Suggested
javadsl.Source.combine rest java.util.List[Source[T, ? <: Any]] java.util.List[? <: Graph[SourceShape[T], ?]]
javadsl.Source.zipN, zipWithN java.util.List[Source[T, ? <: Any]] java.util.List[? <: Graph[SourceShape[T], ?]]
javadsl.Source.mergePrioritizedN java.util.List[Pair[Source[T, ? <: Any], Integer]] java.util.List[? <: Pair[? <: Graph[SourceShape[T], ?], Integer]]
javadsl.Sink.combine rest java.util.List[Sink[U, ?]] java.util.List[? <: Graph[SinkShape[U], ?]]
persistence-typed javadsl.Effect.persist(events) java.util.List[Event] java.util.List[? <: Event]

For example, List<Source<Integer, NotUsed>> sources = ...; Source.zipN(sources) does not compile today, and neither does passing a List<ItemAdded> to Effect().persist(...) when the behavior's event type is Event. The newer list-based Source.combine / Sink.combine overloads and mergeAll already use java.util.List[? <: Graph[...]], and the scaladsl persist takes a covariant immutable.Seq[Event].

Inconsistencies with sibling operators

The same operator has a bound in one class but not in its siblings:

  • mapConcat: Source, SourceWithContext and FlowWithContext use Function[Out, ? <: java.lang.Iterable[T]]; Flow, SubFlow and SubSource take a plain java.lang.Iterable[T].
  • statefulMapConcat: the inner function returns a plain java.lang.Iterable[T] in Source, Flow, SubFlow and SubSource; should be ? <: java.lang.Iterable[T].
  • recoverWith / recoverWithRetries: Source and Flow recoverWith(pf) use ? <: Graph[SourceShape[Out], NotUsed]; SubFlow, SubSource and Flow.recoverWithRetries do not.
  • fanInStrategy / fanOutStrategy: Source.combine(first, second, rest, ...) uses Function[Integer, ? <: Graph[...]]; the list-based Source.combine overload and Sink.combine / Sink.combineMat do not.
Tests

Java tests should pass a variable of the narrower type (which fails to compile before the change), and mimaReportBinaryIssues for stream and persistence-typed should stay clean.

主要言語
Scala
スター
1.7k
フォーク
212
平均マージ
18時間 4分
マージ済み PR(30日)
113

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

apache/pekko のほかの issue

apache/pekko の issue をすべて見る

似ている issue

Scala の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。