Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #5086 Review and rework o.e.j.util.Scanner #5744

Merged
merged 11 commits into from Dec 2, 2020
Expand Up @@ -24,6 +24,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import org.eclipse.jetty.ant.types.Connector;
import org.eclipse.jetty.ant.types.ContextHandlers;
Expand Down Expand Up @@ -135,7 +136,7 @@ public WebAppScannerListener(AntWebAppContext awc)
}

@Override
public void filesChanged(List<String> changedFileNames)
public void filesChanged(Set<String> changedFileNames)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like this. File names are unique by definition, so there is no risk of duplicates. I would not add additional randomness caused by Set. If I really don't care, I'd use Collection -- the Set is supposed to be immutable anyway, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand your point. If it's a List then by definition I can have duplicates in a List, but I can't in a Set. Plus, you can't rely on ordering as it depends on the filesystem in what order scanned directories are visited, so List is a furphy.

{
boolean isScanned = false;
try
Expand Down
Expand Up @@ -140,7 +140,6 @@ protected void doStart() throws Exception
_scanner = new Scanner();
_scanner.setScanDirs(files);
_scanner.setScanInterval(_scanInterval);
_scanner.setRecursive(_recursive);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scanner.setRecursive() was deprecated, but there is no Javadoc about why.
This is the only usage of ScanningAppProvider._recursive which then should also be deprecated and removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

_scanner.setFilenameFilter(_filenameFilter);
_scanner.setReportDirs(true);
_scanner.setScanDepth(1); //consider direct dir children of monitored dir
Expand Down
Expand Up @@ -76,10 +76,15 @@ public void setupEnvironment() throws Exception
if (provider instanceof ScanningAppProvider)
{
_providers++;
((ScanningAppProvider)provider).addScannerListener(new Scanner.ScanListener()
((ScanningAppProvider)provider).addScannerListener(new Scanner.ScanCycleListener()
{
@Override
public void scan()
public void scanStarted(int cycle)
{
}

@Override
public void scanEnded(int cycle)
{
_scans.incrementAndGet();
}
Expand Down
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.Path;
import java.nio.file.PathMatcher;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.MojoExecutionException;
Expand Down Expand Up @@ -191,7 +191,7 @@ protected void configureScanner()
}
scanner.addListener(new Scanner.BulkListener()
{
public void filesChanged(List<String> changes)
public void filesChanged(Set<String> changes)
{
try
{
Expand Down
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.Set;

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Execute;
Expand Down Expand Up @@ -197,7 +197,7 @@ public void configureScanner() throws MojoExecutionException
configureScanTargetPatterns(scanner);
scanner.addListener(new Scanner.BulkListener()
{
public void filesChanged(List<String> changes)
public void filesChanged(Set<String> changes)
{
try
{
Expand Down