Solr
  1. Solr
  2. SOLR-5401

In Solr's ResourceLoader, add a check for @Deprecated annotation in the plugin/analysis/... class loading code, so we print a warning in the log if a deprecated factory class is used

    Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 3.6, 4.5
    • Fix Version/s: 4.6, Trunk
    • Component/s: Schema and Analysis
    • Labels:
      None

      Description

      While changing an antique 3.6 schema.xml to Solr 4.5, I noticed that some factories were deprecated in 3.x and were no longer available in 4.x (e.g. "solr._Language_PorterStemFilterFactory"). If the user would have got a notice before, this could have been prevented and user would have upgraded before.

      In fact the factories were @Deprecated in 3.6, but the Solr loader does not print any warning. My proposal is to add some simple code to SolrResourceLoader that it prints a warning about the deprecated class, if any configuartion setting loads a class with @Deprecated warning. So we can prevent that problem in the future.

      1. SOLR-5401.patch
        7 kB
        Uwe Schindler

        Issue Links

          Activity

          Hide
          Dawid Weiss added a comment -

          It would be better to add some form of a callback listener instead of capturing the whole thing. Solr logs are huge so capturing in memory will very likely OOM on many machines...

          Show
          Dawid Weiss added a comment - It would be better to add some form of a callback listener instead of capturing the whole thing. Solr logs are huge so capturing in memory will very likely OOM on many machines...
          Hide
          Uwe Schindler added a comment -

          Jack Krupansky: I will open another issue to make something for capturing log output from tests available in the solr-testframework package. If this is done, we can add the check for this issue. For now, the whole thing works and already prints some warnings in the dfeault Solr config, which should be cleaned up to be deprecation free (see SOLR-5404).

          Show
          Uwe Schindler added a comment - Jack Krupansky : I will open another issue to make something for capturing log output from tests available in the solr-testframework package. If this is done, we can add the check for this issue. For now, the whole thing works and already prints some warnings in the dfeault Solr config, which should be cleaned up to be deprecation free (see SOLR-5404 ).
          Hide
          ASF subversion and git services added a comment -

          Commit 1537122 from Uwe Schindler in branch 'dev/branches/branch_4x'
          [ https://svn.apache.org/r1537122 ]

          Merged revision(s) 1537119 from lucene/dev/trunk:
          SOLR-5401: SolrResourceLoader logs a warning if a deprecated (factory) class is used in schema or config

          Show
          ASF subversion and git services added a comment - Commit 1537122 from Uwe Schindler in branch 'dev/branches/branch_4x' [ https://svn.apache.org/r1537122 ] Merged revision(s) 1537119 from lucene/dev/trunk: SOLR-5401 : SolrResourceLoader logs a warning if a deprecated (factory) class is used in schema or config
          Hide
          ASF subversion and git services added a comment -

          Commit 1537119 from Uwe Schindler in branch 'dev/trunk'
          [ https://svn.apache.org/r1537119 ]

          SOLR-5401: SolrResourceLoader logs a warning if a deprecated (factory) class is used in schema or config

          Show
          ASF subversion and git services added a comment - Commit 1537119 from Uwe Schindler in branch 'dev/trunk' [ https://svn.apache.org/r1537119 ] SOLR-5401 : SolrResourceLoader logs a warning if a deprecated (factory) class is used in schema or config
          Hide
          Jack Krupansky added a comment -

          I suspect that all the needed logic is sprinkled throughout the Solr logging API. Yes, probably way too much effort for this one test, but it would be good to have lots of other Solr features fully test their error and warning handling, so eventually this piece of test infrastructure would be valuable.

          Show
          Jack Krupansky added a comment - I suspect that all the needed logic is sprinkled throughout the Solr logging API. Yes, probably way too much effort for this one test, but it would be good to have lots of other Solr features fully test their error and warning handling, so eventually this piece of test infrastructure would be valuable.
          Hide
          Uwe Schindler added a comment -

          I think it is too much work for such a stupid test. I think I keep everything as in the patch. The test verifies that just nothing breaks. Everything else would be more complicated than the functionality added.

          Show
          Uwe Schindler added a comment - I think it is too much work for such a stupid test. I think I keep everything as in the patch. The test verifies that just nothing breaks. Everything else would be more complicated than the functionality added.
          Hide
          Uwe Schindler added a comment -

          Jack Krupansky: This test has no Solr running at all, so no way to access this. I think Dawid's idea is a good one, because the testing in solr already uses log4j.

          Show
          Uwe Schindler added a comment - Jack Krupansky : This test has no Solr running at all, so no way to access this. I think Dawid's idea is a good one, because the testing in solr already uses log4j.
          Hide
          Jack Krupansky added a comment -

          Solr has a logging admin API that will return recent log entries.

          For example:

          curl "http://localhost:8983/solr/admin/logging?threshold=WARN&test&since=0&indent=true"
          

          More examples and the API parameters are in the admin API section of my e-book that is currently in progress, but that isn't out yet. The source code is currently your best guide: org.apache.solr.handler.admin.LoggingHandler.

          Show
          Jack Krupansky added a comment - Solr has a logging admin API that will return recent log entries. For example: curl "http: //localhost:8983/solr/admin/logging?threshold=WARN&test&since=0&indent= true " More examples and the API parameters are in the admin API section of my e-book that is currently in progress, but that isn't out yet. The source code is currently your best guide: org.apache.solr.handler.admin.LoggingHandler.
          Hide
          Dawid Weiss added a comment -

          Don't know about solr but for other logging frameworks you attach a listener to the root logger (or the one you're interested in), intercept any log messages, then detach the listener and analyze the forked log contents. Works like a charm for Log4j, don't know if other frameworks have this.

          Show
          Dawid Weiss added a comment - Don't know about solr but for other logging frameworks you attach a listener to the root logger (or the one you're interested in), intercept any log messages, then detach the listener and analyze the forked log contents. Works like a charm for Log4j, don't know if other frameworks have this.
          Hide
          Uwe Schindler added a comment -

          Patch.

          If anybody has an idea how to check inside a test case that something was printed to the Solr logger, please tell me!

          Show
          Uwe Schindler added a comment - Patch. If anybody has an idea how to check inside a test case that something was printed to the Solr logger, please tell me!

            People

            • Assignee:
              Uwe Schindler
              Reporter:
              Uwe Schindler
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development