Hi All,
Group C code reviews will be lead by Sameera for next few weeks. Please
communicate with Sameera and arrange review sessions.
Last week we reviewed some of the User core code. Mainly the
DatabaseUserStoreManager.
Some of the lessons we learn t are as follows,
Use of database connections
If a database connection is opened by a particular method, it should close
the connection in a finally block.
When closing a connection there is possibility that an exception might rise.
In that case we should not through the exception. In other words we should
not throw exceptions in finally block.
try{
}catch(SQLException) {
//log
//throw or handle
}
finally {
Try {
Statement.close();
Resultset.close();
Connection.close()
}catch(SQLException e){
//log
//do not throw exceptions here
}
}
Class/method who created the connection must close the connection. If a
reference is passed to another method, class, that class/method should not
close the connection.
When closing connections, it is better to close all database related
objects, resultSet, statements and connections.
OSGI,
BundleActivator start method should not throw any exception. This leads OSGI
to restart bundle over and over. Therefore bundle activator start method
should catch exceptions & errors and log them to a file.
E.g: -try {
}
Catch (Throwable e) {
//log
//do not throw exceptions
}
Naming,
Should not have names like Statement sqlStmt1 etc … Should
have a meaningful name.
E.g :- Statement updateUserTableSQL
Next reviews
Rajike – ESB Endpoints
Chathuri – Tooling related component
Sameera – Carbon related component
Thanks
AmilaJ
_______________________________________________
Carbon-dev mailing list
[email protected]
https://wso2.org/cgi-bin/mailman/listinfo/carbon-dev