とりわけ、プロパティを読み取り、コンストラクターで getProperty を使用していくつかのプロパティを抽出するクラスを含む jar があります。
jar をテストし、並列スレッドを生成して jmeter でストレスをかけると、場合によっては、一部のプロパティに対して null が返されます。ストレスをためないとこんなことにはなりません。
Windows 10でjdk-14を使用しています。
これは、著作権のためにいくつかの変更を加えた私のソース コードです。
よろしくお願いいたします。
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
}