Bug 63691 - Add a no-op JarScanner
Summary: Add a no-op JarScanner
Alias: None
Product: Tomcat 9
Classification: Unclassified
Component: Catalina (show other bugs)
Version: unspecified
Hardware: PC All
: P2 enhancement (vote)
Target Milestone: -----
Assignee: Tomcat Developers Mailing List
Keywords: Beginner
Depends on:
Reported: 2019-08-24 19:45 UTC by Igal Sapir
Modified: 2020-01-07 11:16 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Igal Sapir 2019-08-24 19:45:49 UTC
When running Tomcat in embedded mode it is many times desired to skip all of the jar scanning in favor of a faster startup.  While it's possible to create an anonymous class, I propose to add a simple NoOp class, e.g. 
org.apache.tomcat.util.scan.NoopJarScanner, possibly with a Singleton instance, which will have do nothing.

Then we'd be able to easily call `context.setJarScanner(NoopJarScanner.INSTANCE)`.

If approved, I'd be happy to implement it.
Comment 1 Mark Thomas 2019-08-30 18:14:15 UTC
Why not just do

System.setProperty("tomcat.util.scan.StandardJarScanFilter.jarsToSkip","*.jar") ?

Untested but you get the idea. Still one line of code for end users and no need to add an entire new class to Tomcat.
Comment 2 Igal Sapir 2019-08-30 18:29:50 UTC
(In reply to Mark Thomas from comment #1)
> Why not just do
> System.setProperty("tomcat.util.scan.StandardJarScanFilter.jarsToSkip","*.
> jar") ?

IIRC then that still reads the directories and then filters them out.  Currently I am using the following:

    new JarScanner() {
      public void scan(JarScanType scanType, ServletContext context, JarScannerCallback callback) {}

       public JarScanFilter getJarScanFilter() { return null; }

       public void setJarScanFilter(JarScanFilter jarScanFilter) {}

It might be negligible compared to the System property that you cited but then again the addition is very minor as well.

If you still think that it's not useful then that's fine and we can just close this ticket as rejected.
Comment 3 Mark Thomas 2019-09-01 19:39:24 UTC
It is a balance. I'm on the fence as to whether this is worth adding or not. If you think it adds value then I'm not going to object.
Comment 4 Chuck Caldarale 2019-09-02 01:24:26 UTC
Could the standard jar scanner recognize the "*.jar" pattern and simply short-circuit all the directory scanning?
Comment 5 Igal Sapir 2019-09-02 16:21:20 UTC
(In reply to Chuck Caldarale from comment #4)
> Could the standard jar scanner recognize the "*.jar" pattern and simply
> short-circuit all the directory scanning?

I can see benefit in that solution for users who use Tomcat regularly (as opposed to Embedded) so I actually like that idea.
Comment 6 Mark Thomas 2019-10-04 16:58:48 UTC
Marking as an enhancement
Comment 7 Mark Thomas 2020-01-07 11:16:50 UTC
Fixed (by isapir) in:
- master for 9.0.31 onwards
- 8.5.x for 8.5.51 onwards