Uploaded image for project: 'Kogito'
  1. Kogito
  2. KOGITO-2902

Checked exceptions in user service are not included in the code-generated resources

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 0.15.0
    • None
    • Core Engine
    • None

      If a user service is declaring some checked exceptions, the resources that are code-generated do not include them. For example if the service isĀ 

      @ApplicationScoped
      public class OperatorSearchService {
      
          public static boolean isAvailable() throws JsonProcessingException, IOException {
              
              ObjectMapper objectMapper = new ObjectMapper();
              //InputStream inputStream = OperatorSearchService.class.getClassLoader().getResourceAsStream("database.json");
              
              String json = "{ \"operator\" : { \"isAvailable\" : true } }";
              JsonNode jsonNode = objectMapper.readTree(json);
              JsonNode availableNode = jsonNode.at("/operator/isAvailable");
              return availableNode.asBoolean();
           }
      }
      

      and a bpmn is using the `isAvailable` method, then the resource that is code-generated is

      package org.kie.kogito.handlers;
      
      @javax.enterprise.context.ApplicationScoped()
      public class OperatorSearchService_isAvailableHandler implements org.kie.api.runtime.process.WorkItemHandler {
      
          @javax.inject.Inject()
          org.acme.OperatorSearchService service;
      
          public void executeWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager workItemManager) {
              java.lang.Object result = service.isAvailable();
              workItemManager.completeWorkItem(workItem.getId(), java.util.Collections.singletonMap("Result", result));
          }
      
          public void abortWorkItem(org.kie.api.runtime.process.WorkItem workItem, org.kie.api.runtime.process.WorkItemManager workItemManager) {
          }
      
          public String getName() {
              return "org.acme.OperatorSearchService.isAvailable";
          }
      }
      

      Since the checked Exception is not declared, then a compilation error is raised as soon as `mvn clean compile quarkus:dev` is run.

      See the reproducer hereĀ https://github.com/r00ta/kogito

            ftirados Francisco Javier Tirado Sarti
            jrota@redhat.com Jacopo Rota (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: