TSK-1337: fixed newly introduced bugs

This commit is contained in:
Mustapha Zorgati 2020-09-02 09:43:44 +02:00
parent 1bbdbf5c70
commit e26e5c65a1
3 changed files with 10 additions and 5 deletions

View File

@ -80,7 +80,7 @@ public class LogfileHistoryServiceImpl implements TaskanaHistory {
} }
private Properties readPropertiesFromFile(String propertiesFile) { private Properties readPropertiesFromFile(String propertiesFile) {
java.util.Properties props = new Properties(); Properties props = new Properties();
boolean loadFromClasspath = loadFromClasspath(propertiesFile); boolean loadFromClasspath = loadFromClasspath(propertiesFile);
try { try {
if (loadFromClasspath) { if (loadFromClasspath) {
@ -93,7 +93,9 @@ public class LogfileHistoryServiceImpl implements TaskanaHistory {
LOGGER.debug("properties were loaded from file {} from classpath.", propertiesFile); LOGGER.debug("properties were loaded from file {} from classpath.", propertiesFile);
} }
} else { } else {
props.load(new FileInputStream(propertiesFile)); try (FileInputStream stream = new FileInputStream(propertiesFile)) {
props.load(stream);
}
LOGGER.debug("properties were loaded from file {}.", propertiesFile); LOGGER.debug("properties were loaded from file {}.", propertiesFile);
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -5,6 +5,7 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import org.springframework.hateoas.IanaLinkRelations; import org.springframework.hateoas.IanaLinkRelations;
import org.springframework.hateoas.Link; import org.springframework.hateoas.Link;
@ -67,7 +68,8 @@ public class TaskHistoryEventListResourceAssembler {
private UriComponentsBuilder getBaseUri() { private UriComponentsBuilder getBaseUri() {
HttpServletRequest request = HttpServletRequest request =
((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); ((ServletRequestAttributes) Objects.requireNonNull(
RequestContextHolder.getRequestAttributes())).getRequest();
UriComponentsBuilder baseUri = UriComponentsBuilder baseUri =
ServletUriComponentsBuilder.fromServletMapping(request).path(request.getRequestURI()); ServletUriComponentsBuilder.fromServletMapping(request).path(request.getRequestURI());

View File

@ -293,7 +293,6 @@ public class TaskanaEngineConfiguration {
return roleMap; return roleMap;
} }
@SuppressWarnings("unused")
public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) { public void setRoleMap(Map<TaskanaRole, Set<String>> roleMap) {
this.roleMap = roleMap; this.roleMap = roleMap;
} }
@ -589,7 +588,9 @@ public class TaskanaEngineConfiguration {
LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile); LOGGER.debug("Role properties were loaded from file {} from classpath.", propertiesFile);
} }
} else { } else {
props.load(new FileInputStream(propertiesFile)); try (FileInputStream stream = new FileInputStream(propertiesFile)) {
props.load(stream);
}
LOGGER.debug("Role properties were loaded from file {}.", propertiesFile); LOGGER.debug("Role properties were loaded from file {}.", propertiesFile);
} }
} catch (IOException e) { } catch (IOException e) {