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

MemoryFileSystem losts contents of files all DRL scripts become "empty" if directory contains a space character

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.7.0.Final
    • 7.4.1.Final, 7.5.0.Final, 7.6.0.Final
    • core engine
    • None
    • Hide

      Create directory with space character.
      Put any *.drl files there.

          private KieContainer createKieContainer() throws IOException {
              final KieServices kieServices = KieServices.get();
      
              final KieFileSystem fs = kieServices.newKieFileSystem();
      
              // iterate all files
              ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
              final Resource[] resources = resourcePatternResolver.getResources(baseDirectory + "*.drl");
              for (Resource res : resources) {
                  logger.info("Add file to build " + res.getFilename());
                  fs.write(ResourceFactory.newUrlResource(res.getURL()));
              }
      
              KieBuilder kieBuilder = kieServices.newKieBuilder(fs);
              kieBuilder.buildAll();
              KieModule kieModule = kieBuilder.getKieModule();
      
              return kieServices.newKieContainer(kieModule.getReleaseId());
          }
      
      
      

      then try to use createKieContainer() - no rules exist.

      Show
      Create directory with space character. Put any *.drl files there. private KieContainer createKieContainer() throws IOException { final KieServices kieServices = KieServices.get(); final KieFileSystem fs = kieServices.newKieFileSystem(); // iterate all files ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); final Resource[] resources = resourcePatternResolver.getResources(baseDirectory + "*.drl" ); for (Resource res : resources) { logger.info( "Add file to build " + res.getFilename()); fs.write(ResourceFactory.newUrlResource(res.getURL())); } KieBuilder kieBuilder = kieServices.newKieBuilder(fs); kieBuilder.buildAll(); KieModule kieModule = kieBuilder.getKieModule(); return kieServices.newKieContainer(kieModule.getReleaseId()); } then try to use createKieContainer() - no rules exist.
    • Workaround Exists
    • Hide

      store all files in directories without spaces or coded symbols

      Show
      store all files in directories without spaces or coded symbols
    • Low
    • NEW
    • NEW

      If a directory where any files are placed contains spaces
      MemoryFileSystem.getFile(String path) returns object with truncated name.

      To fix this error (in version 7.4.0) it is nessassary line 107
      String name = decode( path ).substring( lastSlashPos + 1 );
      replace with
      String name = decode( path.substring( lastSlashPos + 1 ) );

              mfusco@redhat.com Mario Fusco
              akotikhov_jira Alexander Kotikhov (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: