Revision: 1410
http://stripes.svn.sourceforge.net/stripes/?rev=1410&view=rev
Author: bengunter
Date: 2011-03-03 19:40:48 +0000 (Thu, 03 Mar 2011)
Log Message:
-----------
Fixed STS-797: Remove redundant null checks, add some needed ones.
Modified Paths:
--------------
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/DynamicMappingFilter.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBinding.java
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2011-03-03 19:23:45 UTC (rev 1409)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
2011-03-03 19:40:48 UTC (rev 1410)
@@ -147,25 +147,22 @@
getUrlBindingFactory().addBinding(clazz, new UrlBinding(clazz,
binding));
}
- // Only process the class if it's properly annotated
- if (binding != null) {
- // Construct the mapping of event->method for the class
- Map<String, Method> classMappings = new HashMap<String, Method>();
- processMethods(clazz, classMappings);
+ // Construct the mapping of event->method for the class
+ Map<String, Method> classMappings = new HashMap<String, Method>();
+ processMethods(clazz, classMappings);
- // Put the event->method mapping for the class into the set of
mappings
- this.eventMappings.put(clazz, classMappings);
+ // Put the event->method mapping for the class into the set of mappings
+ this.eventMappings.put(clazz, classMappings);
- if (log.getRealLog().isDebugEnabled()) {
- // Print out the event mappings nicely
- for (Map.Entry<String, Method> entry :
classMappings.entrySet()) {
- String event = entry.getKey();
- Method handler = entry.getValue();
- boolean isDefault = DEFAULT_HANDLER_KEY.equals(event);
+ if (log.getRealLog().isDebugEnabled()) {
+ // Print out the event mappings nicely
+ for (Map.Entry<String, Method> entry : classMappings.entrySet()) {
+ String event = entry.getKey();
+ Method handler = entry.getValue();
+ boolean isDefault = DEFAULT_HANDLER_KEY.equals(event);
- log.debug("Bound: ", clazz.getSimpleName(), ".",
handler.getName(), "() ==> ",
- binding, isDefault ? "" : "?" + event);
- }
+ log.debug("Bound: ", clazz.getSimpleName(), ".",
handler.getName(), "() ==> ",
+ binding, isDefault ? "" : "?" + event);
}
}
}
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/DynamicMappingFilter.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/DynamicMappingFilter.java
2011-03-03 19:23:45 UTC (rev 1409)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/DynamicMappingFilter.java
2011-03-03 19:40:48 UTC (rev 1410)
@@ -495,7 +495,7 @@
+ StripesFilter.class.getName() + "']/..", document,
XPathConstants.NODESET);
if (filterNodes == null || filterNodes.getLength() != 1) {
String msg;
- if (filterNodes.getLength() < 1) {
+ if (filterNodes == null || filterNodes.getLength() < 1) {
msg = "StripesFilter is not declared in web.xml. ";
}
else {
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
2011-03-03 19:23:45 UTC (rev 1409)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/StripesRequestWrapper.java
2011-03-03 19:40:48 UTC (rev 1410)
@@ -501,7 +501,7 @@
if (value == null && request.getParameterValues(name) ==
null) {
value = p.getDefaultValue();
}
- if (name != null && value != null) {
+ if (value != null) {
if (params == null) {
params = new LinkedHashMap<String, String[]>();
}
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBinding.java
===================================================================
---
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBinding.java
2011-03-03 19:23:45 UTC (rev 1409)
+++
branches/1.5.x/stripes/src/net/sourceforge/stripes/controller/UrlBinding.java
2011-03-03 19:40:48 UTC (rev 1410)
@@ -43,22 +43,28 @@
public UrlBinding(Class<? extends ActionBean> beanType, String path,
List<Object> components) {
this.beanType = beanType;
this.path = path;
- if (components != null)
+
+ if (components != null && !components.isEmpty()) {
this.components = Collections.unmodifiableList(components);
+ this.parameters = new
ArrayList<UrlBindingParameter>(components.size());
- this.parameters = new
ArrayList<UrlBindingParameter>(this.components.size());
- for (Object component : components) {
- if (component instanceof UrlBindingParameter) {
- this.parameters.add((UrlBindingParameter) component);
+ for (Object component : components) {
+ if (component instanceof UrlBindingParameter) {
+ this.parameters.add((UrlBindingParameter) component);
+ }
}
- }
- if (this.parameters.size() > 0) {
- Object last = this.components.get(this.components.size() - 1);
- if (last instanceof String) {
- this.suffix = (String) last;
+ if (!this.parameters.isEmpty()) {
+ Object last = components.get(components.size() - 1);
+ if (last instanceof String) {
+ this.suffix = (String) last;
+ }
}
}
+ else {
+ this.components = Collections.emptyList();
+ this.parameters = Collections.emptyList();
+ }
}
/**
Modified:
branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
===================================================================
--- branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
2011-03-03 19:23:45 UTC (rev 1409)
+++ branches/1.5.x/stripes/src/net/sourceforge/stripes/util/UrlBuilder.java
2011-03-03 19:40:48 UTC (rev 1410)
@@ -551,12 +551,10 @@
StripesFilter.getConfiguration().getActionResolver().getActionBeanType(url);
}
catch (UrlBindingConflictException e) {
- if (binding != null) {
- UrlBindingConflictException tmp = new
UrlBindingConflictException(binding
- .getBeanType(), e.getPath(), e.getMatches());
- tmp.setStackTrace(e.getStackTrace());
- e = tmp;
- }
+ UrlBindingConflictException tmp = new UrlBindingConflictException(
+ binding.getBeanType(), e.getPath(), e.getMatches());
+ tmp.setStackTrace(e.getStackTrace());
+ e = tmp;
throw e;
}
return url;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development