Possible patch some leaks
This commit is contained in:
parent
06364873ca
commit
99e4d231c2
|
@ -22,6 +22,7 @@ public class LocalFetcher {
|
||||||
JAXBContext context = JAXBContext.newInstance(Config.class);
|
JAXBContext context = JAXBContext.newInstance(Config.class);
|
||||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
Config config = (Config) unmarshaller.unmarshal(is);
|
Config config = (Config) unmarshaller.unmarshal(is);
|
||||||
|
is.close();
|
||||||
ConfigSingle currencyConfig = config.getConfigs().stream().filter(configSingle -> configSingle.getType().equals("currency")).findFirst().get();
|
ConfigSingle currencyConfig = config.getConfigs().stream().filter(configSingle -> configSingle.getType().equals("currency")).findFirst().get();
|
||||||
|
|
||||||
return retrieveData(currencyConfig);
|
return retrieveData(currencyConfig);
|
||||||
|
@ -39,7 +40,7 @@ public class LocalFetcher {
|
||||||
Unmarshaller unmarshaller = context.createUnmarshaller();
|
Unmarshaller unmarshaller = context.createUnmarshaller();
|
||||||
|
|
||||||
Object object = unmarshaller.unmarshal(is);
|
Object object = unmarshaller.unmarshal(is);
|
||||||
|
is.close();
|
||||||
Method reader = null;
|
Method reader = null;
|
||||||
if (configSingle.getParseField() != null && !configSingle.getParseField().isEmpty()) {
|
if (configSingle.getParseField() != null && !configSingle.getParseField().isEmpty()) {
|
||||||
reader = new PropertyDescriptor(configSingle.getParseField(), aClass).getReadMethod();
|
reader = new PropertyDescriptor(configSingle.getParseField(), aClass).getReadMethod();
|
||||||
|
|
|
@ -86,6 +86,7 @@ public class MailServiceImpl implements MailService {
|
||||||
InputStream inputStream = resource.getInputStream();
|
InputStream inputStream = resource.getInputStream();
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
IOUtils.copy(inputStream, writer, "UTF-8");
|
IOUtils.copy(inputStream, writer, "UTF-8");
|
||||||
|
inputStream.close();
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
package eu.eudat.models.rda.mapper;
|
package eu.eudat.models.rda.mapper;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import eu.eudat.models.rda.Language;
|
import eu.eudat.models.rda.Language;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class LanguageRDAMapper {
|
public class LanguageRDAMapper {
|
||||||
private final static Map<String, Object> langMap = new HashMap<>();
|
private final static Map<String, Object> langMap = new HashMap<>();
|
||||||
|
@ -20,9 +19,12 @@ public class LanguageRDAMapper {
|
||||||
static {
|
static {
|
||||||
String json = null;
|
String json = null;
|
||||||
try {
|
try {
|
||||||
json = new BufferedReader(new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8))
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
.lines().collect(Collectors.joining("\n"));
|
InputStreamReader isr = new InputStreamReader(LanguageRDAMapper.class.getClassLoader().getResource("internal/rda-lang-map.json").openStream(), StandardCharsets.UTF_8);
|
||||||
|
json = mapper.readValue(isr, String.class);
|
||||||
|
isr.close();
|
||||||
langMap.putAll(new org.json.JSONObject(json).toMap());
|
langMap.putAll(new org.json.JSONObject(json).toMap());
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue