Skip to content

refactor: convert LimitingTee callbacks Function<T,?> → Consumer<T>#2945

Merged
Naenyn merged 1 commit into
uPortal-Project:masterfrom
bjagg:refactor/limitingtee-function-to-consumer
Apr 22, 2026
Merged

refactor: convert LimitingTee callbacks Function<T,?> → Consumer<T>#2945
Naenyn merged 1 commit into
uPortal-Project:masterfrom
bjagg:refactor/limitingtee-function-to-consumer

Conversation

@bjagg

@bjagg bjagg commented Apr 22, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #2943, adopting the cleaner design @Naenyn proposed. Replaces the @SuppressWarnings/unused workaround 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 ErrorProne CheckReturnValue check 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 his remove_fluid branch 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 @SuppressWarnings version — 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.javaFunction<LimitingTeeWriter, ?>Consumer<LimitingTeeWriter>, .apply(this).accept(this), swap import, update Javadoc reference.
  • LimitingTeeOutputStream.java — same pattern.
  • CachingPortletOutputHandler.java (sole caller) — anonymous Function<> classes → concise lambdas:
    input -> clearCachedWriter()
    input -> clearCachedStream()
    Drop the now-unused com.google.common.base.Function import.

Tests (uPortal-webapp):

  • LimitingTeeWriterTest.java, LimitingTeeOutputStreamTest.java — matching Function-to-lambda updates; drop unused Function imports.
  • PortalRawEventsAggregatorImplTest.javadifferent pattern here: the Function comes from the code-under-test's own API, not our types, so it can't be changed to Consumer. Use Boolean 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 SUCCESSFUL
  • @Naenyn's remove_fluid branch (which has resourceServerVersion=1.5.2 and therefore triggers the underlying Guava @CheckReturnValue check) 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 @SuppressWarnings workaround. Cleaner code, no behavior change.

cc @Naenyn

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 Naenyn merged commit 783b643 into uPortal-Project:master Apr 22, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants