Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-5434

Incorrect warning about file declaring wrong package

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: core engine
    • Labels:
      None
    • Sprint:
      2020 Week 25-27 (from Jun 15)
    • Docs QE Status:
      NEW
    • QE Status:
      NEW

      Description

      I am running Drools in a Spring-Boot jar and get the following warning statement File 'BOOT-INF/classes/com/example/test/TEST.drl' is in folder 'BOOT-INF/classes/com/example/test' but declares package 'com.example.test'. It is advised to have a correspondance between package and folder names. The package name in the drl file is correct, the problem is just that BOOT-INF.classes. isn't considered when evaluating if printing the warning or not.

      I have tracked it down to KieBuilderImpl.java, method isFileInKieBase. The last 2 lines in that method calls:

      // packageNameForFile prints warning if package in .drl file is not same as flatted directory structure
      // Does not care about SUPPORTED_RESOURCES_ROOTS, thus prints the warning
      String pkgNameForFile = packageNameForFile( fileName, folderNameForFile, !useFolders, file );
      
      // Does care about SUPPORTED_RESOURCES_ROOTS, so the drl file is loaded
      return isPackageInKieBase( kieBase, pkgNameForFile );
      

      As it is implemented right now, the warning might either be a false-positive (and still get loaded), or the package is wrong (and the file is not loaded).

      Voting to include the SUPPORTED_RESOURCES_ROOTS as valid prefixes when checking if the warning should be printed.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mfusco Mario Fusco
                  Reporter:
                  magnus_larsson Magnus Larsson
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: