See, we are talking around 40 defects that should be straightforward to clean up. Mostly a question of moving if statements or extra try catch or finally.
[1] org.sakaiproject.reports.logic.impl.LoadArtifactResultProcessor
Failure to close statement line 274, need to make non anonymous and expressly close in finally
protected void loadArtifactTypes(String artifactIds, Map<String, ArtifactHolder> artifactsToLoad) {
Connection conn = null;
ResultSet rs = null;
try {
conn = getDataSource().getConnection();
rs = conn.createStatement().executeQuery(
"select id, sub_type from dw_resource where id in (" + artifactIds + ")");
while (rs.next()) {
String id = rs.getString(1);
String type = rs.getString(2);
ArtifactHolder holder = (ArtifactHolder) artifactsToLoad.get(id);
if (holder != null) {
holder.artifactType = type;
}
}
}
catch (SQLException e) {
logger.error("", e);
throw new RuntimeException(e);
}
finally {
//ensure that the results set is clsoed
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
//ensure that the connection is closed
if (conn != null) {
try {
conn.close();
}
catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
}
}
[2] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
Line 1271 Useless object creation, result never used
JDOMResult result = new JDOMResult();
[3] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
NPE if scheduler is null line 2054
if (scheduler == null) {
logger.error("Scheduler is down!");
}
JobDetail jd = null;
try {
JobBeanWrapper job = getJobBeanWrapper();
if (job != null) {
Failure to close InputStream can cause File descriptor leakage
InputStream stream = wrapper.getParentClass().getResourceAsStream(wrapper.getDefinitionFileLocation());
if (wrapper.getParentClass().getResourceAsStream(xsl.getXslLink()) != null){
Wow this is difficult, the whole method should be looked at as by catching Exception with
catch (Exception e) {
throw new RuntimeException("Loaded report def failed", e);
}
You are hiding java.io.Exceptions etc, that have to be closed properly. I would suggest re-implementing the try catch block as a series with a finally. The anonymous creation of streams etc. should be removed.
Alan Berg added a comment - 08-Jan-2010 00:55 Also checked reports:
See: http://www.ibm.com/developerworks/java/library/j-jtp03216.html
[1] org.sakaiproject.reports.logic.impl.LoadArtifactResultProcessor
Failure to close statement line 274, need to make non anonymous and expressly close in finally
protected void loadArtifactTypes(String artifactIds, Map<String, ArtifactHolder> artifactsToLoad) {
Connection conn = null;
ResultSet rs = null;
try {
conn = getDataSource().getConnection();
rs = conn.createStatement().executeQuery(
"select id, sub_type from dw_resource where id in (" + artifactIds + ")");
while (rs.next()) {
String id = rs.getString(1);
String type = rs.getString(2);
ArtifactHolder holder = (ArtifactHolder) artifactsToLoad.get(id);
if (holder != null) {
holder.artifactType = type;
}
}
}
catch (SQLException e) {
logger.error("", e);
throw new RuntimeException(e);
}
finally {
//ensure that the results set is clsoed
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
//ensure that the connection is closed
if (conn != null) {
try {
conn.close();
}
catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
}
}
[2] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
Line 1271 Useless object creation, result never used
JDOMResult result = new JDOMResult();
[3] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
NPE if scheduler is null line 2054
if (scheduler == null) {
logger.error("Scheduler is down!");
}
JobDetail jd = null;
try {
JobBeanWrapper job = getJobBeanWrapper();
if (job != null) {
jd = scheduler.getJobDetail(report.getReportId().toString(), reportGroup);
[4,5] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
Failure to close InputStream can cause File descriptor leakage
InputStream stream = wrapper.getParentClass().getResourceAsStream(wrapper.getDefinitionFileLocation());
if (wrapper.getParentClass().getResourceAsStream(xsl.getXslLink()) != null){
Wow this is difficult, the whole method should be looked at as by catching Exception with
catch (Exception e) {
throw new RuntimeException("Loaded report def failed", e);
}
You are hiding java.io.Exceptions etc, that have to be closed properly. I would suggest re-implementing the try catch block as a series with a finally. The anonymous creation of streams etc. should be removed.
Alan Berg added a comment - 05-Feb-2010 02:02 A speedy resolution to this review, will allow QA to test as part of the 2.7 QA season. Please review the progress already made by SAK-17647
Noah Botimer added a comment - 15-Mar-2010 08:39 These are complete from my perspective. I am not aware of any problems at present. The reports change has been reverted and the tool is starting up.
See: http://www.ibm.com/developerworks/java/library/j-jtp03216.html
[1] org.sakaiproject.reports.logic.impl.LoadArtifactResultProcessor
Failure to close statement line 274, need to make non anonymous and expressly close in finally
protected void loadArtifactTypes(String artifactIds, Map<String, ArtifactHolder> artifactsToLoad) {
Connection conn = null;
ResultSet rs = null;
try {
conn = getDataSource().getConnection();
rs = conn.createStatement().executeQuery(
"select id, sub_type from dw_resource where id in (" + artifactIds + ")");
while (rs.next()) {
String id = rs.getString(1);
String type = rs.getString(2);
ArtifactHolder holder = (ArtifactHolder) artifactsToLoad.get(id);
if (holder != null) {
holder.artifactType = type;
}
}
}
catch (SQLException e) {
logger.error("", e);
throw new RuntimeException(e);
}
finally {
//ensure that the results set is clsoed
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
//ensure that the connection is closed
if (conn != null) {
try {
conn.close();
}
catch (SQLException e) {
if (logger.isDebugEnabled()) {
logger.debug("loadArtifactTypes(String, Map) caught " + e);
}
}
}
}
}
[2] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
Line 1271 Useless object creation, result never used
JDOMResult result = new JDOMResult();
[3] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
NPE if scheduler is null line 2054
if (scheduler == null) {
logger.error("Scheduler is down!");
}
JobDetail jd = null;
try {
JobBeanWrapper job = getJobBeanWrapper();
if (job != null) {
jd = scheduler.getJobDetail(report.getReportId().toString(), reportGroup);
[4,5] org.sakaiproject.reports.logic.impl.ReportsManagerImpl
Failure to close InputStream can cause File descriptor leakage
InputStream stream = wrapper.getParentClass().getResourceAsStream(wrapper.getDefinitionFileLocation());
if (wrapper.getParentClass().getResourceAsStream(xsl.getXslLink()) != null){
Wow this is difficult, the whole method should be looked at as by catching Exception with
catch (Exception e) {
throw new RuntimeException("Loaded report def failed", e);
}
You are hiding java.io.Exceptions etc, that have to be closed properly. I would suggest re-implementing the try catch block as a series with a finally. The anonymous creation of streams etc. should be removed.