Skip to content

Commit d2b37b7

Browse files
committed
Prevent NPE and removed unecessary WARN message.
1 parent 7239bb8 commit d2b37b7

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

source/src/main/java/org/cerberus/core/crud/dao/impl/TestDataLibDAO.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import java.sql.Connection;
4545
import java.sql.PreparedStatement;
4646
import java.sql.ResultSet;
47+
import java.sql.ResultSetMetaData;
4748
import java.sql.SQLException;
4849
import java.sql.Statement;
4950
import java.sql.Timestamp;
@@ -1046,7 +1047,7 @@ public TestDataLib loadFromResultSet(ResultSet resultSet) throws SQLException {
10461047
subDataParsingAnswer = ParameterParserUtil.returnEmptyStringIfNull(resultSet.getString("tdd.parsingAnswer"));
10471048
subDataColumnPosition = ParameterParserUtil.returnEmptyStringIfNull(resultSet.getString("tdd.columnPosition"));
10481049
} catch (Exception ex) {
1049-
LOG.warn(ex.toString());
1050+
LOG.debug(ex.toString());
10501051
}
10511052

10521053
return factoryTestDataLib.create(testDataLibID, name, system, environment, country, privateData, group, type, database, script, databaseUrl, service, servicePath,

source/src/main/java/org/cerberus/core/engine/execution/impl/RecorderService.java

+26-24
Original file line numberDiff line numberDiff line change
@@ -543,38 +543,40 @@ public TestCaseExecutionFile recordExeLog(TestCaseExecution execution) {
543543
LOG.debug("Starting to save Execution log File.");
544544

545545
TestCaseExecutionFile object = null;
546-
String test = execution.getTest();
547-
String testCase = execution.getTestCase();
546+
if ((execution != null) && (execution.getExecutionLog() != null)) {
547+
String test = execution.getTest();
548+
String testCase = execution.getTestCase();
548549

549-
try {
550-
Recorder recorder = this.initFilenames(execution.getId(), test, testCase, null, null, null, null, null, 0, "exeLog", "log", false);
551-
File dir = new File(recorder.getFullPath());
552-
dir.mkdirs();
550+
try {
551+
Recorder recorder = this.initFilenames(execution.getId(), test, testCase, null, null, null, null, null, 0, "exeLog", "log", false);
552+
File dir = new File(recorder.getFullPath());
553+
dir.mkdirs();
553554

554-
File file = new File(recorder.getFullFilename());
555+
File file = new File(recorder.getFullFilename());
555556

556-
try (FileOutputStream fileOutputStream = new FileOutputStream(file);) {
557-
for (ExecutionLog executionLog : execution.getExecutionLog()) {
558-
fileOutputStream.write(executionLog.getLogText().getBytes());
559-
fileOutputStream.write("\r\n".getBytes());
560-
LOG.debug(executionLog.getLogText());
561-
}
557+
try (FileOutputStream fileOutputStream = new FileOutputStream(file);) {
558+
for (ExecutionLog executionLog : execution.getExecutionLog()) {
559+
fileOutputStream.write(executionLog.getLogText().getBytes());
560+
fileOutputStream.write("\r\n".getBytes());
561+
LOG.debug(executionLog.getLogText());
562+
}
562563

563-
LOG.info("File saved : {}", recorder.getFullFilename());
564+
LOG.info("File saved : {}", recorder.getFullFilename());
564565

565-
// Index file created to database.
566-
object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Execution Log", recorder.getRelativeFilenameURL(), "TXT", "", null, "", null);
567-
testCaseExecutionFileService.save(object);
566+
// Index file created to database.
567+
object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Execution Log", recorder.getRelativeFilenameURL(), "TXT", "", null, "", null);
568+
testCaseExecutionFileService.save(object);
568569

569-
} catch (IOException ex) {
570+
} catch (IOException ex) {
571+
LOG.error(ex.toString(), ex);
572+
} catch (WebDriverException ex) {
573+
LOG.debug("Exception recording execution log on execution : {}", execution.getId(), ex);
574+
object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Execution Log [ERROR]", recorder.getRelativeFilenameURL(), "TXT", "", null, "", null);
575+
testCaseExecutionFileService.save(object);
576+
}
577+
} catch (CerberusException ex) {
570578
LOG.error(ex.toString(), ex);
571-
} catch (WebDriverException ex) {
572-
LOG.debug("Exception recording execution log on execution : {}", execution.getId(), ex);
573-
object = testCaseExecutionFileFactory.create(0, execution.getId(), recorder.getLevel(), "Execution Log [ERROR]", recorder.getRelativeFilenameURL(), "TXT", "", null, "", null);
574-
testCaseExecutionFileService.save(object);
575579
}
576-
} catch (CerberusException ex) {
577-
LOG.error(ex.toString(), ex);
578580
}
579581
return object;
580582

0 commit comments

Comments
 (0)