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

   **Motivation:**
   
   `Archive.zip(deflateCompression)` added in #1829 exposes `scala.Option[Int]` 
in the **javadsl**. A Java caller has to write:
   
   ```java
   Archive.zip(Some$.MODULE$.apply(Deflater.NO_COMPRESSION))
   ```
   
   with the boxing that implies. Every other javadsl in the repo uses 
`java.util.Optional` or a plain value for this kind of parameter 
(`LogRotatorSink`, `s3/javadsl/S3`, `GoogleSettings`).
   
   The overload is new in 2.0.0 and has not appeared in a release (not in any 
tag), so the signature can still be corrected without a compatibility story.
   
   Neither DSL validated the level either. An out-of-range value reached 
`ZipOutputStream.setLevel` inside `preStart`, so the stream failed at 
materialization with `invalid compression level` rather than at the call site.
   
   **Modification:**
   
   The javadsl overload now takes a plain `Int`. The compression domain is 
`0-9` plus `Deflater.DEFAULT_COMPRESSION` (-1), so `Optional` adds nothing over 
an int — there is no "absent" case that -1 does not already express. Both 
overloads delegate to a private `zipFlow` that keeps the `Option`-based 
scaladsl call.
   
   The scaladsl keeps `Option[Int]`, which is idiomatic there, and gains a 
`require` that rejects a level outside `0-9` and `DEFAULT_COMPRESSION`, so an 
invalid value now fails at the call site with a message naming the bound.
   
   **Result:**
   
   Java callers write `Archive.zip(Deflater.NO_COMPRESSION)`. An invalid level 
is rejected when the flow is constructed rather than when it is materialized.
   
   **Tests:**
   
   Added two tests to the Java `ArchiveTest`:
   - one builds a zip via `Archive.zip(Deflater.NO_COMPRESSION)` and 
round-trips it through `ArchiveHelper.unzip` — this is precisely the call the 
old signature made awkward from Java, so it is the test that would have caught 
the problem
   - one asserts levels `10` and `-2` are rejected
   
   Added matching scaladsl tests for the rejection and for 
`Deflater.DEFAULT_COMPRESSION` being accepted.
   
   Java tests: 6 total, 0 failed. Scala: 26 total, 0 failed. Ran 
`file/mimaReportBinaryIssues` (clean), the module scalafmt checks and 
`javafmtCheckAll`.
   
   **References:**
   
   Follow-up to #1829.


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