Package net.sourceforge.pmd.reporting
Class DeterministicOutputListenerWrapper
- java.lang.Object
-
- net.sourceforge.pmd.reporting.DeterministicOutputListenerWrapper
-
- All Implemented Interfaces:
AutoCloseable,GlobalAnalysisListener
public class DeterministicOutputListenerWrapper extends Object implements GlobalAnalysisListener
A listener that mediates access to another listener to order events in a predetermined, stable way. When running PMD with multiple threads, file listeners may be called in any order. This makes runs non-deterministic, as Renderers can output reports in the particular order files were processed, which varies between runs. This class will reorder the events by buffering them, to call the methods of the underlying GlobalAnalysisListener in a deterministic order.Any renderer whose output may depend on ordering of files should be shielded by an instance of this wrapper. Note that each wrapper maintains its own buffer so it should be
- Since:
- 7.12.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sourceforge.pmd.reporting.GlobalAnalysisListener
GlobalAnalysisListener.ViolationCounterListener
-
-
Constructor Summary
Constructors Constructor Description DeterministicOutputListenerWrapper(GlobalAnalysisListener listener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Notify the implementation that the analysis ended, ie all files have been processed.ListenerInitializerinitializer()Provides an initializer to gather analysis context before events start occurring.voidonConfigError(Report.ConfigurationError error)Record a configuration error.FileAnalysisListenerstartFileAnalysis(TextFile file)Returns a file listener that will handle events occurring during the analysis of the given file.StringtoString()
-
-
-
Constructor Detail
-
DeterministicOutputListenerWrapper
public DeterministicOutputListenerWrapper(GlobalAnalysisListener listener)
-
-
Method Detail
-
initializer
public ListenerInitializer initializer()
Description copied from interface:GlobalAnalysisListenerProvides an initializer to gather analysis context before events start occurring.- Specified by:
initializerin interfaceGlobalAnalysisListener- Returns:
- A listener initializer.
-
startFileAnalysis
public FileAnalysisListener startFileAnalysis(TextFile file)
Description copied from interface:GlobalAnalysisListenerReturns a file listener that will handle events occurring during the analysis of the given file. The new listener may receive events as soon as this method returns. The analysis stops when theFileAnalysisListener.close()method is called.- Specified by:
startFileAnalysisin interfaceGlobalAnalysisListener- Parameters:
file- File to be processed- Returns:
- A new listener
-
close
public void close() throws ExceptionDescription copied from interface:GlobalAnalysisListenerNotify the implementation that the analysis ended, ie all files have been processed. This listener won't be used after this is called.Closing listeners multiple times should have no effect.
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceGlobalAnalysisListener- Throws:
Exception- If an error occurs. For example, renderer listeners may throwIOException
-
onConfigError
public void onConfigError(Report.ConfigurationError error)
Description copied from interface:GlobalAnalysisListenerRecord a configuration error. This happens before the start of file analysis.- Specified by:
onConfigErrorin interfaceGlobalAnalysisListener
-
-