This issue has been created
There is 1 update.
 
 
XWiki Rendering / cid:jira-generated-image-avatar-63edce9b-8fdf-411c-8591-4dd8f1d6516a XRENDERING-812 Open

PrintTextListener duplicates the no-op listener callbacks of EmptyWemListener

 
View issue   ยท   Add comment
 

Issue created

 
cid:jira-generated-image-avatar-1beba5a3-006e-4e1d-ab83-53483e42bbf8 Vincent Massol created this issue on 25/Aug/26 10:16
 
Summary: PrintTextListener duplicates the no-op listener callbacks of EmptyWemListener
Issue Type: cid:jira-generated-image-avatar-63edce9b-8fdf-411c-8591-4dd8f1d6516a Improvement
Assignee: Unassigned
Components: Development Issues only
Created: 25/Aug/26 10:16
Priority: cid:jira-generated-image-static-major-bace7a9e-0e01-44dd-9356-b6a90f602974 Major
Reporter: Vincent Massol
Description:

Problem

PrintTextListener implements IWemListener directly and redeclares 35 of the interface's callbacks with empty bodies, even though EmptyWemListener โ€” another IWemListener implementation sitting in the same package โ€” already provides exactly those empty implementations.

As a result both classes carry the same run of identically-signed empty methods, in the same order. SonarCloud's copy-paste detector reports a 134-line duplicated block between them:

  • PrintTextListener lines 95-228
  • EmptyWemListener lines 76-197

Consequence

The duplication counts against the SonarCloud quality gate of org.xwiki.rendering:xwiki-rendering: the new_duplicated_lines_density condition reports 4.5% against a 3% threshold, so the gate is red. Every other condition passes.

The duplication itself is long-standing; it only started counting once a comment-only change re-dated some of those lines into the new-code period.

Proposal

Make PrintTextListener extend EmptyWemListener and drop the no-op callbacks it then no longer needs to declare, so that the empty implementations live in one place only.

Notes:

  • There is no user-visible change and no behaviour change.
  • beginDocument(WikiParameters) has to stay an explicit no-op override rather than being inherited: EmptyWemListener forwards it to the no-arg beginDocument(), which would start invoking a subclass override that previously was never called.
  • The change is binary compatible โ€” the methods that stop being declared stay reachable through the new superclass, so code compiled against the previous version keeps loading and running. It does add EmptyWemListener as a supertype, which Revapi reports as java.class.nonFinalClassInheritsFromNewClass on the four affected classes, so it needs a justified ignore.
 
 

1 update

 
cid:jira-generated-image-avatar-1beba5a3-006e-4e1d-ab83-53483e42bbf8 Changes by Vincent Massol on 25/Aug/26 10:16
 
Fix Version: 18.8.0-rc-1