Detailed information about defect clone:
15-C0.H1.M0.L0_D_U_02.war
Nickname of the defect
fixed-date-input-record
Brief desctiption
Date in New Exam Date is always set to 2100-12-12 20:00
.
How to activate the defect
-
Click on Login in the header
-
Username
pedant
, password pass
, click on Login button
-
Click on New Exam Date
-
Enter
2050-01-02 10:00
in Date and time of examination
-
Click on Save new exam date
-
Click on My Exam dates
Visibility of the defect
Parts
StudentService |
TeacherService |
DateUtility |
GradeDAO |
UserDAO |
BaseStudentService
|
BaseTeacherService
|
E02DateUtility
|
GradeTypeDaoCriteria
|
UserDaoCriteria
|
URL to the defect source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/utils/dates/error/E02DateUtility.java
Source code with the injected defect
/**
* DELIBERATE ERROR
*
* This method returns Date object from static string 2100-12-12 20:00, 2100-12-12 or 20:00
* It depend on string date format in parameter
*
* @param stringDate String representation of date
* @return Date object
*/
@Override
@ErrorMethod(errorMessage = "This method returns Date object from static string 2100-12-12 20:00, 2100-12-12 or 20:00")
public Date stringToDate(String stringDate) {
try {
switch (stringDate.length()) {
case 16: // yyyy-MM-dd HH:mm
log.error(propertyLoader.getProperty("log.E02DateUtility.stringToDate"));
return sdfDateAndTime.parse("2100-12-12 20:00");
case 10: // yyyy-MM-dd
log.error(propertyLoader.getProperty("log.E02DateUtility.stringToDate"));
return sdfDate.parse("2100-12-12");
case 5: // HH:mm
log.error(propertyLoader.getProperty("log.E02DateUtility.stringToDate"));
return sdfTime.parse("20:00");
}
} catch (ParseException e) {
log.error("Error during date parsing!", e);
}
return null;
}
URL to the correct source code
https://gitlab.kiv.zcu.cz/herout/TbUIS-UIS/blob/master/src/main/java/cz/zcu/kiv/matyasj/dp/utils/dates/correct/BaseDateUtility.java
Correct source code
/**
* This method returns Date object from string representation given in
* method parameter.
*
* @param stringDate String representation of date
* @return Date object
*/
@Override
public Date stringToDate(String stringDate) {
try {
switch (stringDate.length()) {
case 16: // yyyy-MM-dd HH:mm
log.info("Parsing string representation of date to Date object");
return sdfDateAndTime.parse(stringDate);
case 10: // yyyy-MM-dd
log.info("Parsing string representation of date to Date object");
return sdfDate.parse(stringDate);
case 5: // HH:mm
log.info("Parsing string representation of date to Date object");
return sdfTime.parse(stringDate);
}
} catch (ParseException e) {
log.error("Error during date parsing!", e);
}
return null;
}
Logged information up to failure
2019-10-12 18:13:30.338 -- INFO LogHelper:31 - HHH000204: Processing PersistenceUnitInfo [name: cz.zcu.kiv.matyasj.dp]
2019-10-12 18:13:30.588 -- INFO Version:46 - HHH000412: Hibernate Core {5.4.1.Final}
2019-10-12 18:13:31.025 -- INFO Version:49 - HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2019-10-12 18:13:31.496 -- INFO C3P0ConnectionProvider:116 - HHH010002: C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/uis-web-db
2019-10-12 18:13:31.496 -- INFO C3P0ConnectionProvider:117 - HHH10001001: Connection properties: {password=****, useUnicode=true, handling_mode=DELAYED_ACQUISITION_AND_HOLD, characterEncoding=UTF-8, user=uis-web}
2019-10-12 18:13:31.496 -- INFO C3P0ConnectionProvider:120 - HHH10001003: Autocommit mode: false
2019-10-12 18:13:31.699 -- INFO C3P0ConnectionProvider:200 - HHH10001007: JDBC isolation level:
2019-10-12 18:13:32.074 -- INFO Dialect:158 - HHH000400: Using dialect: org.hibernate.dialect.MySQL55Dialect
2019-10-12 18:13:33.808 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@644e2230] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-12 18:13:36.089 -- INFO access:47 - HHH10001501: Connection obtained from JdbcConnectionAccess [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator$ConnectionProviderJdbcConnectionAccess@5f45d7db] for (non-JTA) DDL execution was not in auto-commit mode; the Connection 'local transaction' will be committed and the Connection will be set into auto-commit mode.
2019-10-12 18:13:48.122 -- INFO JtaPlatformInitiator:52 - HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2019-10-12 18:13:48.356 -- INFO SecurityConfig:75 - SECURITY JDBC authentication process is running
2019-10-12 18:13:50.700 -- INFO SecurityConfig:93 - Authorization configuration process is running
2019-10-12 18:13:51.043 -- INFO BaseInitializer:97 - Initializing ...
2019-10-12 18:13:57.591 -- INFO BaseInitializer:463 - Initialized!
2019-10-12 18:13:57.747 -- INFO BaseInitializer:97 - Initializing ...
2019-10-12 18:17:31.404 -- INFO LoginController:30 - Request for login view
2019-10-12 18:17:38.564 -- INFO UserDaoCriteria:74 - User with username pedant found.
2019-10-12 18:17:38.626 -- INFO SecurityConfig:121 - Success login - pedant
2019-10-12 18:17:38.626 -- INFO SecurityConfig:125 - User login role: ROLE_TEACHER
2019-10-12 18:17:38.642 -- INFO UserDaoCriteria:74 - User with username pedant found.
2019-10-12 18:17:38.673 -- INFO OverviewController:53 - Request for overview of teacher with id 30 for view.
2019-10-12 18:17:40.532 -- INFO NewExamDateController:44 - Request for retrieving new exam date form view.
2019-10-12 18:17:40.532 -- INFO UserDaoCriteria:74 - User with username pedant found.
2019-10-12 18:17:40.563 -- INFO BaseTeacherService:92 - Getting list of taught subjects for teacher with id 30.
2019-10-12 18:17:48.878 -- INFO UserDaoCriteria:74 - User with username pedant found.
2019-10-12 18:17:48.893 -- INFO NewExamDateController:95 - Request from user with id 30 for saving new exam date with subject id 1, date 2019-10-15 10:00 and maximal number of participants 1.
2019-10-12 18:17:48.893 -- INFO BaseTeacherService:385 - Creating new examination term for subject with id 1, teacher with id 30, date 2019-10-15 10:00 and maximal number of participants 1.
2019-10-12 18:17:48.893 -- ERROR E02DateUtility:76 - INJECTED_ERROR: E02DateUtility_stringToDate_returns_Date_object_from_static_string_20_00_or_2100-12-12_or_2100-12-12_20-00
Overview of functional tests full log
Overview of acceptance tests full report