refactor: convert LimitingTee callbacks Function<T,?> → Consumer<T>#2945
Merged
Naenyn merged 1 commit intoApr 22, 2026
Merged
Conversation
Replaces the @SuppressWarnings/unused workaround just landed in uPortal-Project#2943 with the cleaner design @Naenyn proposed: the callback's return was always discarded (the `?` wildcard on Function was a tell), so java.util.function.Consumer<T> is the correct type. With Consumer, .accept() returns void and ErrorProne's CheckReturnValue check doesn't apply at all — no suppression needed. Adopts @Naenyn's approach verbatim from his remove_fluid-branch work (Naenyn/uPortal@f2e3a459). His force-push came in after uPortal-Project#2943 was already squashed and merged, so this PR lands the same set of changes as a follow-up. Scope (6 files, +23/−48): - LimitingTeeWriter.java : Function<T,?> → Consumer<T>, .apply → .accept - LimitingTeeOutputStream.java : same pattern - CachingPortletOutputHandler.java (sole caller): anonymous Function<> classes → concise `input -> clearCachedWriter()` and `input -> clearCachedStream()` lambdas; drop unused import - LimitingTeeWriterTest.java, LimitingTeeOutputStreamTest.java : matching Function-to-lambda updates; drop unused Function import - PortalRawEventsAggregatorImplTest.java : different case — the Function here is part of the code-under-test's own API and can't be changed, so use `Boolean ignored = …` to capture the return (same shape @Naenyn used; aligns with the ErrorProne convention) Verified locally: - :uPortal-rendering:compileJava → BUILD SUCCESSFUL - :uPortal-webapp:compileTestJava → BUILD SUCCESSFUL (master baseline; the 1.5.2-Guava trigger is already covered by @Naenyn's remove_fluid branch building clean with these same hunks.) Co-Authored-By: Bill Smith <wsmith@unicon.net> Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Naenyn
approved these changes
Apr 22, 2026
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #2943, adopting the cleaner design @Naenyn proposed. Replaces the
@SuppressWarnings/unusedworkaround that just landed with the correct type for a fire-and-forget callback:java.util.function.Consumer<T>. With Consumer,.accept()returns void and the ErrorProneCheckReturnValuecheck doesn't apply at all — no suppression needed.Context — why this is a follow-up rather than an update to #2943
@Naenyn had pushed his Consumer-based version (
Naenyn/uPortal@f2e3a459) to hisremove_fluidbranch and asked me to adopt it. I force-pushed the cherry-pick onto #2943's branch, but the merge of #2943 had already resolved against the original@SuppressWarningsversion — the better approach didn't make it in.This PR lands the same set of changes as a clean follow-up, with @Naenyn credited as co-author. When his #2915 rebases master, these hunks will be no-ops (already on master) and his PR shrinks correspondingly.
Scope (6 files, +25/−56)
Source (
uPortal-rendering):LimitingTeeWriter.java—Function<LimitingTeeWriter, ?>→Consumer<LimitingTeeWriter>,.apply(this)→.accept(this), swap import, update Javadoc reference.LimitingTeeOutputStream.java— same pattern.CachingPortletOutputHandler.java(sole caller) — anonymousFunction<>classes → concise lambdas:com.google.common.base.Functionimport.Tests (
uPortal-webapp):LimitingTeeWriterTest.java,LimitingTeeOutputStreamTest.java— matching Function-to-lambda updates; drop unused Function imports.PortalRawEventsAggregatorImplTest.java— different pattern here: theFunctioncomes from the code-under-test's own API, not our types, so it can't be changed to Consumer. UseBoolean ignored = …to capture the return (same shape @Naenyn used; aligns with the ErrorProne convention for the cases where the type genuinely can't be changed).Validation
./gradlew :uPortal-rendering:compileJava→ BUILD SUCCESSFUL./gradlew :uPortal-webapp:compileTestJava→ BUILD SUCCESSFULremove_fluidbranch (which hasresourceServerVersion=1.5.2and therefore triggers the underlying Guava@CheckReturnValuecheck) already builds clean with these exact changes — so the fix addresses the real failure mode.Net effect
After this lands, master will carry @Naenyn's original Consumer design rather than the
@SuppressWarningsworkaround. Cleaner code, no behavior change.cc @Naenyn