Skip to content

Commit

Permalink
[kie-issues#698] Fix SCA quality issue on generated code (#3287)
Browse files Browse the repository at this point in the history
Co-authored-by: BAMOE CI <bamoe.ci@ibm.com>
  • Loading branch information
gitgabrio and BAMOE CI authored Nov 23, 2023
1 parent adec9f0 commit 8460bca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.kie.dmn.kogito.quarkus.example;

import java.io.InputStream;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.ws.rs.Consumes;
Expand All @@ -29,6 +31,7 @@
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.ResponseBuilder;

import org.kie.dmn.feel.codegen.feel11.CodegenStringUtil;
import org.kie.kogito.Application;
import org.kie.kogito.dmn.rest.DMNEvaluationErrorException;
import org.kie.kogito.dmn.rest.DMNJSONUtils;
Expand Down Expand Up @@ -70,10 +73,9 @@ public Response dmn($inputType$ variables) {
@GET
@Produces(MediaType.APPLICATION_XML)
public String dmn() throws java.io.IOException {
return new String(org.drools.util.IoUtils.
readBytesFromInputStream(this.getClass()
.getResourceAsStream(org.kie.dmn.feel.codegen.feel11.CodegenStringUtil.escapeIdentifier("$modelName$") +
".dmn_nologic")));
try (InputStream is = this.getClass().getResourceAsStream(CodegenStringUtil.escapeIdentifier("$modelName$") + ".dmn_nologic")) {
return new String(org.drools.util.IoUtils.readBytesFromInputStream(Objects.requireNonNull(is)));
}
}

private ResponseBuilder extractContextIfSucceded(KogitoDMNResult result){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@
*/
package org.kie.dmn.kogito.quarkus.example;

import java.io.InputStream;
import java.util.AbstractMap.SimpleEntry;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.stream.Collectors;

import org.kie.dmn.feel.codegen.feel11.CodegenStringUtil;
import org.kie.kogito.Application;
import org.kie.kogito.dmn.rest.DMNEvaluationErrorException;
import org.kie.kogito.dmn.rest.DMNJSONUtils;
Expand Down Expand Up @@ -73,10 +76,9 @@ public ResponseEntity<?> dmn(@RequestBody(required = false) $inputType$ variable

@GetMapping(produces = MediaType.APPLICATION_XML_VALUE)
public String dmn() throws java.io.IOException {
return new String(org.drools.util.IoUtils.
readBytesFromInputStream(this.getClass()
.getResourceAsStream(org.kie.dmn.feel.codegen.feel11.CodegenStringUtil.escapeIdentifier("$modelName$") +
".dmn_nologic")));
try (InputStream is = this.getClass().getResourceAsStream(CodegenStringUtil.escapeIdentifier("$modelName$") + ".dmn_nologic")) {
return new String(org.drools.util.IoUtils.readBytesFromInputStream(Objects.requireNonNull(is)));
}
}

private Entry<HttpStatus, ?> buildFailedEvaluationResponse(KogitoDMNResult result){
Expand Down

0 comments on commit 8460bca

Please sign in to comment.