I have a jar that contains a class that, among other things, reads a properties and extracts some properties with getProperty in the constructor.
When I test the jar and I stress it with jmeter by raising parallels threads, only in some cases it returns null for some properties. This doesn't happen when I don't stress it out.
I'm using jdk-14 over windows 10.
This is my source code with some modifications due to copyright.
Grateful in advance for your help !!
public class Connector {
private static properties;
private static int port = 0;
private static String host = null;
private static int timeOutRead = 0;
private static int timeOutConnect = 0;
private static final Logger log = Logger.getLogger(Connector.class);
public Connector() {
try {
Logg logg = new Logg();
logg.initLoggerProperties();
log.info("Constructor of Connector class");
properties = readProperties("configurations/conector.properties");
port = Integer.parseInt(properties.getProperty("port"));
host = properties.getProperty("host");
timeOutRead = Integer.parseInt(properties.getProperty("timeOutRead"));
timeOutConnect = Integer.parseInt(properties.getProperty("timeOutConnect"));
properties.clear();
log.info(metodo + "port[" + port + "].");
log.info(metodo + "host[" + host + "].");
log.info(metodo + "timeOutRead[" + timeOutRead+ "].");
log.info(metodo + "timeOutConnect["+ timeOutConnect + "].");
} catch (Exception ex) {
log.error(metodo
+ "[ConectorCIO]::[ConectorCIO]::Se ha producido una exception del tipo:"
+ ex.getMessage(), ex);
}
}
private Properties readProperties(String pathAndName)
throws FileNotFoundException, IOException {
InputStream is = getClass().getClassLoader().getResourceAsStream(pathAndName);
Properties properties = new Properties();
properties.load(is);
is.close();
return properties;
}
//others functions
}