Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5377

Remove redundant logging on failed module start

    XMLWordPrintable

Details

    • Enhancement
    • Status: Closed
    • Should
    • Resolution: Fixed
    • None
    • Core 2.2.0
    • None
    • None
    • Low

    Description

      Private method ModuleFactory.getModuleFromFile catches ModuleExceptions, adds logging that replicates whats inside the Exception and rethrows the ModuleException which causes the ModuleException to be logged twice with almost identical information.

      see examples

      before: tested on openmrs 2.1
      after: is on latest master of openmrs core with inclining the method

      The message in the UI remain the same, differences in logs are shown below.

      `invalid.file`

      which is an empty file created by `touch invalid.file`

      BEFORE

      ERROR - ModuleFactory.getModuleFromFile(544) |2018-03-22 07:39:44,067| Module was null.
      org.openmrs.module.ModuleException: Module file cannot be null
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:83)
      at org.openmrs.module.ModuleFactory.getModuleFromFile(ModuleFactory.java:538)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:107)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:94)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)
      WARN - ModuleListController.onSubmit(156) |2018-03-22 07:39:44,069| Unable to load and start module
      org.openmrs.module.ModuleException: Module file cannot be null
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:83)
      at org.openmrs.module.ModuleFactory.getModuleFromFile(ModuleFactory.java:538)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:107)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:94)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)

      AFTER

      WARN - ModuleListController.onSubmit(156) |2018-03-22 07:20:31,203| Unable to load and start module
      org.openmrs.module.ModuleException: Module file cannot be null
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:79)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:109)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:96)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)

      `reporting-one-class.jar`

      a valid jar with only one class, so definitely not a valid omod

      BEFORE

      ERROR - ModuleFactory.getModuleFromFile(542) |2018-03-22 07:37:59,907| Error getting module object from file reporting-one-class.jar
      org.openmrs.module.ModuleException: Module file does not have the correct '.omod' file extension Module: reporting-one-class.jar
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:88)
      at org.openmrs.module.ModuleFactory.getModuleFromFile(ModuleFactory.java:538)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:107)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:94)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)
      WARN - ModuleListController.onSubmit(156) |2018-03-22 07:37:59,911| Unable to load and start module
      org.openmrs.module.ModuleException: Module file does not have the correct '.omod' file extension Module: reporting-one-class.jar
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:88)
      at org.openmrs.module.ModuleFactory.getModuleFromFile(ModuleFactory.java:538)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:107)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:94)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)

      AFTER

      WARN - ModuleListController.onSubmit(156) |2018-03-22 07:21:56,321| Unable to load and start module
      org.openmrs.module.ModuleException: Module file does not have the correct '.omod' file extension Module: reporting-one-class.jar
      at org.openmrs.module.ModuleFileParser.<init>(ModuleFileParser.java:84)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:109)
      at org.openmrs.module.ModuleFactory.loadModule(ModuleFactory.java:96)
      at org.openmrs.module.web.controller.ModuleListController.onSubmit(ModuleListController.java:153)

      Gliffy Diagrams

        Attachments

          Activity

            People

              teleivo Ivo Ulrich
              teleivo Ivo Ulrich
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: