|
From: Janek B. <ya...@st...> - 2004-02-19 11:54:33
|
findbugs 0.7.1 located 3 possible null pointer dereferences in
spring.jar (RC1). I've pasted the relevant source code here along with a
count of other potential bugs located by findbugs.
Not short circuited logic:
org.springframework.web.servlet.mvc.AbstractWizardFormController.setPages(String[])
public final void setPages(String[] pages) {
if (pages == null | pages.length == 0) {
throw new IllegalArgumentException("No wizard pages defined");
}
this.pages = pages;
}
viewClass could be null when getName() is invoked:
org.springframework.web.servlet.view.UrlBasedViewResolver.setViewClass(Class)
public void setViewClass(Class viewClass) {
if (viewClass == null || !requiredViewClass().isAssignableFrom(viewClass)) {
throw new IllegalArgumentException("Given View class [" + viewClass.getName() + "] is not of type [" +
requiredViewClass().getName() + "]");
}
this.viewClass = viewClass;
}
Should the method exit when factory is found to be undefined?
org.springframework.web.servlet.view.tiles.TilesView.
protected void renderMergedOutputModel(Map model, HttpServletRequest request,
HttpServletResponse response) throws Exception {
if (!response.isCommitted()) {
response.setContentType(getContentType());
}
// get definitions factory
DefinitionsFactory factory = (DefinitionsFactory)
getWebApplicationContext().getServletContext().
getAttribute(TilesUtilImpl.DEFINITIONS_FACTORY);
if (factory == null) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
"Tiles definitions factory not found: TilesConfigurer not defined?");
}
// get component definition
ComponentDefinition definition = factory.getDefinition(getUrl(), request, getServletContext());
findbugs also noted potential bugs in 11 other categories:
Dropped or ignored exception: 1
Dubious method used: 7
Method returning array may expose internal representation: 15
Equal objects must have equal hashcodes: 6
Mutable static field: 7
Using notify() rather than notifyAll() in method: 1
Redundant comparison to null: 2
Should be static inner class: 2
Incorrect definition of serializable class: 6
Unread field: 1
Unused field: 2
I picked the easiest category (potential NPEs) to highlight. Whether the remaining bugs are important or actually bugs at all requires a bit more thought!
-Janek
|