Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

whitespace, cleanup, STS warnings

  • Loading branch information...
commit 1a25afe461b004bcf893313f5b08ba9d6b6ffd2a 1 parent e777140
Burt Beckwith authored smaldini committed
Showing with 180 additions and 185 deletions.
  1. +9 −9 gradle/findbugs.gradle
  2. +2 −5 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/GrailsScriptRunner.java
  3. +14 −12 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/support/MetaClassRegistryCleaner.java
  4. +4 −5 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/AbstractDependenciesConfigurer.java
  5. +1 −0  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
  6. +7 −5 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/AbstractGrailsPlugin.java
  7. +101 −91 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPlugin.java
  8. +3 −1 ...nate/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractFindByPersistentMethod.java
  9. +0 −6 ...plugin-controllers/src/main/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformer.java
  10. +1 −4 ...-plugin-mimetypes/src/main/groovy/org/codehaus/groovy/grails/plugins/web/mimes/MimeTypesGrailsPlugin.groovy
  11. +0 −1  ...lugin-testing/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestForTransformation.java
  12. +3 −3 ...-plugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingEvaluator.java
  13. +2 −5 grails-test-suite-uber/src/test/groovy/grails/test/mixin/ServiceAndMockForTests.groovy
  14. +6 −9 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/GrailsPluginManagerTests.groovy
  15. +3 −3 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/plugins/PluginDescriptorReaderTests.groovy
  16. +1 −2  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/GrailsDispatcherServlet.java
  17. +12 −11 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java
  18. +6 −8 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java
  19. +3 −3 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/GroovyPageTagBody.java
  20. +1 −1  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/LayoutWriterStack.java
  21. +1 −1  settings.gradle
View
18 gradle/findbugs.gradle
@@ -8,17 +8,17 @@ task findbugs(dependsOn: install) << {
findbugs(home: findbugsHome, output: "xml:withMessages", outputFile: "$buildDir/findbugs-report/grails-fb.xml", jvmargs: "-Xmx768M") {
auxClasspath() {
for(sub in subprojects) {
- pathElement(path: sub.sourceSets.main.compileClasspath.asPath)
- }
+ pathElement(path: sub.sourceSets.main.compileClasspath.asPath)
+ }
}
sourcePath() {
- for (sub in subprojects) {
- sub.sourceSets.main.groovy.srcDirs.each { srcDir ->
- if (srcDir.exists()) {
- pathElement(path: srcDir.absolutePath)
- }
- }
- }
+ for (sub in subprojects) {
+ sub.sourceSets.main.groovy.srcDirs.each { srcDir ->
+ if (srcDir.exists()) {
+ pathElement(path: srcDir.absolutePath)
+ }
+ }
+ }
}
auxAnalyzepath() {
fileset dir: homeDistDir, includes: "grails-*.jar"
View
7 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/GrailsScriptRunner.java
@@ -150,8 +150,6 @@ public static void main(String[] args) {
return;
}
- String version = System.getProperty("grails.version");
-
ScriptAndArgs script = processArgumentsAndReturnScriptName(commandLine);
// Get hold of the GRAILS_HOME environment variable if it is available.
@@ -205,7 +203,8 @@ public static void main(String[] args) {
script.name = null;
}
if (script.name == null) {
- console.updateStatus("Loading Grails " + (version != null ? version : build.getGrailsVersion()));
+ String version = System.getProperty("grails.version");
+ console.updateStatus("Loading Grails " + (version == null ? build.getGrailsVersion() : version));
build.loadConfig();
if (resolveDeps) {
@@ -285,7 +284,6 @@ else if (commandLine.getEnvironment() != null) {
info.inputName = commandLine.getCommandName();
info.name = GrailsNameUtils.getNameFromScript(commandLine.getCommandName());
- info.args = commandLine.getRemainingArgsString();
return info;
}
@@ -812,6 +810,5 @@ private static void addCommandScripts(File dir, List<Resource> scripts) {
public String inputName;
public String name;
public String env;
- public String args;
}
}
View
26 grails-bootstrap/src/main/groovy/org/codehaus/groovy/grails/cli/support/MetaClassRegistryCleaner.java
@@ -15,17 +15,20 @@
*/
package org.codehaus.groovy.grails.cli.support;
-import groovy.lang.*;
+import groovy.lang.ExpandoMetaClass;
+import groovy.lang.GroovySystem;
+import groovy.lang.MetaClass;
+import groovy.lang.MetaClassRegistryChangeEvent;
+import groovy.lang.MetaClassRegistryChangeEventListener;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
-import java.util.List;
-import groovy.lang.MetaClassRegistryChangeEvent;
-import groovy.lang.MetaClassRegistryChangeEventListener;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
+
import org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl;
/**
@@ -54,13 +57,13 @@ public static void cleanAndRemove(MetaClassRegistryCleaner cleaner) {
}
public void updateConstantMetaClass(MetaClassRegistryChangeEvent cmcu) {
- if(!cleaning) {
+ if (!cleaning) {
MetaClass oldMetaClass = cmcu.getOldMetaClass();
Class classToUpdate = cmcu.getClassToUpdate();
Object instanceToUpdate = cmcu.getInstance();
if (instanceToUpdate == null && (cmcu.getNewMetaClass() instanceof ExpandoMetaClass)) {
updateMetaClassOfClass(oldMetaClass, classToUpdate);
- } else if(instanceToUpdate != null) {
+ } else if (instanceToUpdate != null) {
updateMetaClassOfInstance(oldMetaClass, instanceToUpdate);
}
}
@@ -81,7 +84,7 @@ private void updateMetaClassOfInstance(MetaClass oldMetaClass, Object instanceTo
private void updateMetaClassOfClass(MetaClass oldMetaClass, Class classToUpdate) {
if (oldMetaClass != null) {
Object current = alteredClasses.get(classToUpdate);
- if(current == null || current == NO_CUSTOM_METACLASS) {
+ if (current == null || current == NO_CUSTOM_METACLASS) {
alteredClasses.put(classToUpdate, oldMetaClass);
}
}
@@ -120,7 +123,7 @@ private void cleanMetaClassOfClass(MetaClassRegistryImpl registry) {
Set<Class> classes = new HashSet<Class>(alteredClasses.keySet());
for (Class aClass : classes) {
Object alteredMetaClass = alteredClasses.get(aClass);
- if(alteredMetaClass == NO_CUSTOM_METACLASS) {
+ if (alteredMetaClass == NO_CUSTOM_METACLASS) {
registry.removeMetaClass(aClass);
}
else {
@@ -139,18 +142,17 @@ public IdentityWeakReference(Object referent) {
hash = System.identityHashCode(referent);
}
+ @Override
public int hashCode() {
return hash;
}
+ @Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
- IdentityWeakReference ref = (IdentityWeakReference) obj;
- return this.get() == ref.get();
+ return get() == ((IdentityWeakReference)obj).get();
}
-
}
-
}
View
9 ...-bootstrap/src/main/groovy/org/codehaus/groovy/grails/resolve/config/AbstractDependenciesConfigurer.java
@@ -201,18 +201,17 @@ private void addDependency(String scope, Map<Object, Object> dependency, Closure
if (configurer != null) {
dependencyDescriptor.configure(configurer);
}
- if(!isExcluded(context, dependencyDescriptor)) {
-
+ if (!isExcluded(dependencyDescriptor)) {
addDependency(scope, dependencyDescriptor);
}
}
- private boolean isExcluded(DependencyConfigurationContext context, EnhancedDefaultDependencyDescriptor dependencyDescriptor) {
+ private boolean isExcluded(EnhancedDefaultDependencyDescriptor dependencyDescriptor) {
ExcludeRule[] excludeRules = context.getExcludeRules();
- if(excludeRules != null) {
+ if (excludeRules != null) {
ArtifactId aid = new ArtifactId(dependencyDescriptor.getDependencyId(),PatternMatcher.ANY_EXPRESSION,PatternMatcher.ANY_EXPRESSION,PatternMatcher.ANY_EXPRESSION);
for (ExcludeRule excludeRule : excludeRules) {
- if(MatcherHelper.matches(excludeRule.getMatcher(), excludeRule.getId(), aid )) {
+ if (MatcherHelper.matches(excludeRule.getMatcher(), excludeRule.getId(), aid )) {
return true;
}
}
View
1  grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/GrailsASTUtils.java
@@ -649,6 +649,7 @@ public static boolean hasAnnotation(final ClassNode classNode, final Class<? ext
*/
public static boolean hasAnyAnnotations(final ClassNode classNode, final Class<? extends Annotation>... annotationsToLookFor) {
return CollectionUtils.exists(Arrays.asList(annotationsToLookFor), new Predicate() {
+ @SuppressWarnings({ "unchecked", "rawtypes" })
public boolean evaluate(Object object) {
return hasAnnotation(classNode, (Class)object);
}
View
12 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/AbstractGrailsPlugin.java
@@ -17,6 +17,12 @@
import grails.util.GrailsNameUtils;
import groovy.lang.GroovyObjectSupport;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.codehaus.groovy.grails.commons.AbstractGrailsClass;
import org.codehaus.groovy.grails.commons.GrailsApplication;
import org.codehaus.groovy.grails.plugins.support.WatchPattern;
@@ -25,10 +31,6 @@
import org.springframework.util.Assert;
import org.w3c.dom.Element;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* Abstract implementation that provides some default behaviours
*
@@ -93,7 +95,7 @@ public void setBasePlugin(boolean isBase) {
this.isBase = isBase;
}
- public java.util.List<WatchPattern> getWatchedResourcePatterns() {
+ public List<WatchPattern> getWatchedResourcePatterns() {
return Collections.emptyList();
}
View
192 grails-core/src/main/groovy/org/codehaus/groovy/grails/plugins/DefaultGrailsPlugin.java
@@ -284,11 +284,13 @@ private void evaluateObservedPlugins() {
}
private void evaluatePluginStatus() {
- if (pluginBean.isReadableProperty(STATUS)) {
- Object statusObj = GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, STATUS);
- if (statusObj != null) {
- status = statusObj.toString().toLowerCase();
- }
+ if (!pluginBean.isReadableProperty(STATUS)) {
+ return;
+ }
+
+ Object statusObj = GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, STATUS);
+ if (statusObj != null) {
+ status = statusObj.toString().toLowerCase();
}
}
@@ -380,20 +382,18 @@ else if (referencedResources instanceof List) {
}
private void addBaseLocationPattern(List<String> resourceList, final String baseLocation, String pattern) {
- if (baseLocation != null) {
- final String reloadLocationResourcePattern = getResourcePatternForBaseLocation(baseLocation, pattern);
- resourceList.add(reloadLocationResourcePattern);
- }
- else {
- resourceList.add(pattern);
- }
+ resourceList.add(baseLocation == null ? pattern : getResourcePatternForBaseLocation(baseLocation, pattern));
}
private String getResourcePatternForBaseLocation(String baseLocation, String resourcePath) {
String location = baseLocation;
if (!location.endsWith(File.separator)) location = location + File.separator;
- if (resourcePath.startsWith(".")) resourcePath = resourcePath.substring(1);
- else if (resourcePath.startsWith("file:./")) resourcePath = resourcePath.substring(7);
+ if (resourcePath.startsWith(".")) {
+ resourcePath = resourcePath.substring(1);
+ }
+ else if (resourcePath.startsWith("file:./")) {
+ resourcePath = resourcePath.substring(7);
+ }
resourcePath = "file:" + location + resourcePath;
return resourcePath;
}
@@ -404,24 +404,27 @@ private void evaluatePluginVersion() {
}
Object vobj = plugin.getProperty(VERSION);
- if (vobj != null) {
- version = vobj.toString();
- }
- else {
+ if (vobj == null) {
throw new PluginException("Plugin " + this + " must specify a version. eg: def version = 0.1");
}
+
+ version = vobj.toString();
}
private void evaluatePluginEvictionPolicy() {
- if (pluginBean.isReadableProperty(EVICT)) {
- List pluginsToEvict = (List) GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, EVICT);
- if (pluginsToEvict != null) {
- evictionList = new String[pluginsToEvict.size()];
- int index = 0;
- for (Object o : pluginsToEvict) {
- evictionList[index++] = o != null ? o.toString() : "";
- }
- }
+ if (!pluginBean.isReadableProperty(EVICT)) {
+ return;
+ }
+
+ List pluginsToEvict = (List) GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, EVICT);
+ if (pluginsToEvict == null) {
+ return;
+ }
+
+ evictionList = new String[pluginsToEvict.size()];
+ int index = 0;
+ for (Object o : pluginsToEvict) {
+ evictionList[index++] = o == null ? "" : o.toString();
}
}
@@ -443,10 +446,12 @@ private void evaluatePluginLoadAfters() {
@SuppressWarnings("unchecked")
private void evaluatePluginDependencies() {
- if (pluginBean.isReadableProperty(DEPENDS_ON)) {
- dependencies = (Map) GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, DEPENDS_ON);
- dependencyNames = dependencies.keySet().toArray(new String[dependencies.size()]);
+ if (!pluginBean.isReadableProperty(DEPENDS_ON)) {
+ return;
}
+
+ dependencies = (Map) GrailsClassUtils.getPropertyOrStaticPropertyOrFieldValue(plugin, DEPENDS_ON);
+ dependencyNames = dependencies.keySet().toArray(new String[dependencies.size()]);
}
@Override
@@ -476,18 +481,19 @@ public BeanBuilder beans(Closure closure) {
return bb;
}
-
public void doWithApplicationContext(ApplicationContext ctx) {
try {
- if (pluginBean.isReadableProperty(DO_WITH_APPLICATION_CONTEXT)) {
- Closure c = (Closure)plugin.getProperty(DO_WITH_APPLICATION_CONTEXT);
- if (enableDocumentationGeneration()) {
- DocumentationContext.getInstance().setActive(true);
- }
+ if (!pluginBean.isReadableProperty(DO_WITH_APPLICATION_CONTEXT)) {
+ return;
+ }
- c.setDelegate(this);
- c.call(new Object[]{ctx});
+ Closure c = (Closure)plugin.getProperty(DO_WITH_APPLICATION_CONTEXT);
+ if (enableDocumentationGeneration()) {
+ DocumentationContext.getInstance().setActive(true);
}
+
+ c.setDelegate(this);
+ c.call(new Object[]{ctx});
}
finally {
if (enableDocumentationGeneration()) {
@@ -502,23 +508,25 @@ private boolean enableDocumentationGeneration() {
public void doWithRuntimeConfiguration(RuntimeSpringConfiguration springConfig) {
- if (pluginBean.isReadableProperty(DO_WITH_SPRING)) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Plugin " + this + " is participating in Spring configuration...");
- }
+ if (!pluginBean.isReadableProperty(DO_WITH_SPRING)) {
+ return;
+ }
- Closure c = (Closure)plugin.getProperty(DO_WITH_SPRING);
- BeanBuilder bb = new BeanBuilder(getParentCtx(),springConfig, application.getClassLoader());
- Binding b = new Binding();
- b.setVariable("application", application);
- b.setVariable("manager", getManager());
- b.setVariable("plugin", this);
- b.setVariable("parentCtx", getParentCtx());
- b.setVariable("resolver", getResolver());
- bb.setBinding(b);
- c.setDelegate(bb);
- bb.invokeMethod("beans", new Object[]{c});
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Plugin " + this + " is participating in Spring configuration...");
}
+
+ Closure c = (Closure)plugin.getProperty(DO_WITH_SPRING);
+ BeanBuilder bb = new BeanBuilder(getParentCtx(),springConfig, application.getClassLoader());
+ Binding b = new Binding();
+ b.setVariable("application", application);
+ b.setVariable("manager", getManager());
+ b.setVariable("plugin", this);
+ b.setVariable("parentCtx", getParentCtx());
+ b.setVariable("resolver", getResolver());
+ bb.setBinding(b);
+ c.setDelegate(bb);
+ bb.invokeMethod("beans", new Object[]{c});
}
@Override
@@ -589,20 +597,17 @@ public void doc(String text) {
* @return the watchedResources
*/
public Resource[] getWatchedResources() {
- if (watchedResources.length == 0) {
- if (watchedResourcePatternReferences != null) {
- for (String resourcesReference : watchedResourcePatternReferences) {
- try {
- Resource[] tmp = resolver.getResources(resourcesReference);
- if (tmp.length>0) {
- watchedResources = (Resource[])ArrayUtils.addAll(watchedResources, tmp);
- }
- }
- catch (Exception e) {
- // ignore
+ if (watchedResources.length == 0 && watchedResourcePatternReferences != null) {
+ for (String resourcesReference : watchedResourcePatternReferences) {
+ try {
+ Resource[] resources = resolver.getResources(resourcesReference);
+ if (resources.length > 0) {
+ watchedResources = (Resource[])ArrayUtils.addAll(watchedResources, resources);
}
}
-
+ catch (Exception ignored) {
+ // ignore
+ }
}
}
return watchedResources;
@@ -672,6 +677,7 @@ public void setWatchedResources(Resource[] watchedResources) throws IOException
public Log getLog() {
return LOG;
}
+
public GrailsPlugin getPlugin() {
return this;
}
@@ -687,14 +693,16 @@ public void setParentApplicationContext(ApplicationContext parent) {
public void refresh() {
// do nothing
Resource descriptor = getDescriptor();
- if (application != null && descriptor != null) {
- ClassLoader parent = application.getClassLoader();
- GroovyClassLoader gcl = new GroovyClassLoader(parent);
- try {
- initialisePlugin(gcl.parseClass(descriptor.getFile()));
- } catch (Exception e) {
- LOG.error("Error refreshing plugin: " + e.getMessage(), e);
- }
+ if (application == null || descriptor == null) {
+ return;
+ }
+
+ ClassLoader parent = application.getClassLoader();
+ GroovyClassLoader gcl = new GroovyClassLoader(parent);
+ try {
+ initialisePlugin(gcl.parseClass(descriptor.getFile()));
+ } catch (Exception e) {
+ LOG.error("Error refreshing plugin: " + e.getMessage(), e);
}
}
@@ -772,27 +780,31 @@ private void invokeOnConfigChangeListener(Map event) {
}
private void callEvent(Closure closureHook, Map event) {
- if (closureHook != null) {
- closureHook.setDelegate(this);
- closureHook.call(new Object[]{event});
+ if (closureHook == null) {
+ return;
}
+
+ closureHook.setDelegate(this);
+ closureHook.call(new Object[]{event});
}
private void invokeOnChangeListener(Map event) {
onChangeListener.setDelegate(this);
onChangeListener.call(new Object[]{event});
+ if (!(applicationContext instanceof GenericApplicationContext)) {
+ return;
+ }
+
// Apply any factory post processors in case the change listener has changed any
// bean definitions (GRAILS-5763)
- if (applicationContext instanceof GenericApplicationContext) {
- GenericApplicationContext ctx = (GenericApplicationContext) applicationContext;
- ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory();
- for (BeanFactoryPostProcessor postProcessor : ctx.getBeanFactoryPostProcessors()) {
- try {
- postProcessor.postProcessBeanFactory(beanFactory);
- } catch (IllegalStateException e) {
- // post processor doesn't allow running again, just continue
- }
+ GenericApplicationContext ctx = (GenericApplicationContext) applicationContext;
+ ConfigurableListableBeanFactory beanFactory = ctx.getBeanFactory();
+ for (BeanFactoryPostProcessor postProcessor : ctx.getBeanFactoryPostProcessors()) {
+ try {
+ postProcessor.postProcessBeanFactory(beanFactory);
+ } catch (IllegalStateException e) {
+ // post processor doesn't allow running again, just continue
}
}
}
@@ -821,13 +833,11 @@ public void doArtefactConfiguration() {
LOG.error("This class is not an ArtefactHandler:" + artefactClass.getName());
}
}
+ else if (artefact instanceof ArtefactHandler) {
+ application.registerArtefactHandler((ArtefactHandler) artefact);
+ }
else {
- if (artefact instanceof ArtefactHandler) {
- application.registerArtefactHandler((ArtefactHandler) artefact);
- }
- else {
- LOG.error("This object is not an ArtefactHandler:" + artefact + "[" + artefact.getClass().getName() + "]");
- }
+ LOG.error("This object is not an ArtefactHandler:" + artefact + "[" + artefact.getClass().getName() + "]");
}
}
}
View
4 ...e/src/main/groovy/org/codehaus/groovy/grails/orm/hibernate/metaclass/AbstractFindByPersistentMethod.java
@@ -53,7 +53,9 @@ protected Object getResult(Criteria crit) {
return null;
}
- protected Criteria buildCriteria(Session session, DetachedCriteria detachedCriteria, Closure additionalCriteria, Class clazz, Object[] arguments, String operator, List expressions) {
+ protected Criteria buildCriteria(Session session, DetachedCriteria<?> detachedCriteria,
+ Closure<?> additionalCriteria, Class<?> clazz, Object[] arguments,
+ String operator, List<?> expressions) {
Criteria crit = getCriteria(datastore, application, session, detachedCriteria, additionalCriteria, clazz);
if (arguments.length > 0) {
if (arguments[0] instanceof Map<?, ?>) {
View
6 ...gin-controllers/src/main/groovy/org/codehaus/groovy/grails/compiler/web/ControllerActionTransformer.java
@@ -15,7 +15,6 @@
*/
package org.codehaus.groovy.grails.compiler.web;
-import grails.build.logging.GrailsConsole;
import grails.util.BuildSettings;
import grails.util.CollectionUtils;
import grails.validation.ASTValidateableHelper;
@@ -62,22 +61,17 @@
import org.codehaus.groovy.ast.stmt.ReturnStatement;
import org.codehaus.groovy.ast.stmt.Statement;
import org.codehaus.groovy.classgen.GeneratorContext;
-import org.codehaus.groovy.control.Janitor;
import org.codehaus.groovy.control.SourceUnit;
-import org.codehaus.groovy.control.messages.SyntaxErrorMessage;
-import org.codehaus.groovy.control.messages.WarningMessage;
import org.codehaus.groovy.grails.commons.ControllerArtefactHandler;
import org.codehaus.groovy.grails.compiler.injection.AstTransformer;
import org.codehaus.groovy.grails.compiler.injection.GrailsASTUtils;
import org.codehaus.groovy.grails.compiler.injection.GrailsArtefactClassInjector;
import org.codehaus.groovy.grails.web.plugins.support.WebMetaUtils;
-import org.codehaus.groovy.syntax.SyntaxException;
import org.codehaus.groovy.syntax.Token;
import org.codehaus.groovy.syntax.Types;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.validation.MapBindingResult;
-
/**
* Enhances controller classes by converting closures actions to method actions and binding
* request parameters to action arguments.
View
5 ...ugin-mimetypes/src/main/groovy/org/codehaus/groovy/grails/plugins/web/mimes/MimeTypesGrailsPlugin.groovy
@@ -32,7 +32,7 @@ import org.springframework.context.ApplicationContext
* @author Graeme Rocher
* @since 1.0
*/
-class MimeTypesGrailsPlugin {
+class MimeTypesGrailsPlugin {
def version = GrailsUtil.getGrailsVersion()
def dependsOn = [core:version, servlets:version, controllers:version]
@@ -43,7 +43,6 @@ class MimeTypesGrailsPlugin {
final mimeTypesBeanRef = ref(MimeType.BEAN_NAME)
final grailsAppBeanRef = ref("grailsApplication")
-
grailsMimeUtility(DefaultMimeUtility, mimeTypesBeanRef)
requestMimeTypesApi(RequestMimeTypesApi, grailsAppBeanRef, mimeTypesBeanRef)
responseMimeTypesApi(ResponseMimeTypesApi, grailsAppBeanRef, mimeTypesBeanRef)
@@ -58,6 +57,4 @@ class MimeTypesGrailsPlugin {
responseEnhancer.addApi ctx.getBean("responseMimeTypesApi")
responseEnhancer.enhance HttpServletResponse.metaClass
}
-
}
-
View
1  ...in-testing/src/main/groovy/org/codehaus/groovy/grails/compiler/injection/test/TestForTransformation.java
@@ -71,7 +71,6 @@
public class TestForTransformation extends TestMixinTransformation {
private static final ClassNode MY_TYPE = new ClassNode(TestFor.class);
- private static final String MY_TYPE_NAME = "@" + MY_TYPE.getNameWithoutPackage();
private static final Token ASSIGN = Token.newSymbol("=", -1, -1);
protected static final Map<String, Class> artefactTypeToTestMap = new HashMap<String, Class>();
View
6 ...ugin-url-mappings/src/main/groovy/org/codehaus/groovy/grails/web/mapping/DefaultUrlMappingEvaluator.java
@@ -385,9 +385,9 @@ private Object _invoke(String methodName, Object arg, Object delegate) {
if(binding != null) {
Map bindingVariables = binding.getVariables();
- Object parseRequest = getParseRequest(Collections.EMPTY_MAP,bindingVariables);
- if(parseRequest instanceof Boolean) {
- urlMapping.setParseRequest((Boolean)parseRequest);
+ Object parse = getParseRequest(Collections.EMPTY_MAP, bindingVariables);
+ if (parse instanceof Boolean) {
+ urlMapping.setParseRequest((Boolean)parse);
}
}
configureUrlMapping(urlMapping);
View
7 grails-test-suite-uber/src/test/groovy/grails/test/mixin/ServiceAndMockForTests.groovy
@@ -1,7 +1,6 @@
package grails.test.mixin
-import grails.test.mixin.*
-import org.junit.*
+import org.junit.Test
@TestFor(MyService)
class ServiceAndMockForTests {
@@ -24,9 +23,7 @@ class ServiceAndMockForTests {
@Test
void testProvaUsingMockForAgain() {
def mockForUtilsControl = mockFor(MockForUtils2)
- mockForUtilsControl.demand.isMockForWorking(1..1) {->
- return true
- }
+ mockForUtilsControl.demand.isMockForWorking(1..1) { -> true }
service.utils = mockForUtilsControl.createMock()
assert service.prova()
View
15 grails-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/commons/GrailsPluginManagerTests.groovy
@@ -98,12 +98,12 @@ hibernate {
assertFalse manager.hasGrailsPlugin("disabled")
}
- void testDefaultGrailsPluginManager() throws Exception {
+ void testDefaultGrailsPluginManager() {
DefaultGrailsPluginManager manager = new DefaultGrailsPluginManager(RESOURCE_PATH,ga)
assertEquals(1, manager.getPluginResources().length)
}
- void testLoadPlugins() throws Exception {
+ void testLoadPlugins() {
GrailsPluginManager manager = new DefaultGrailsPluginManager(RESOURCE_PATH,ga)
manager.loadPlugins()
@@ -119,24 +119,21 @@ hibernate {
assertNull(plugin)
}
- void testWithLoadLastPlugin() throws Exception {
+ void testWithLoadLastPlugin() {
def manager = new DefaultGrailsPluginManager([MyGrailsPlugin,AnotherGrailsPlugin,ShouldLoadLastGrailsPlugin] as Class[], ga)
manager.loadPlugins()
}
- void testDependencyResolutionFailure() throws Exception {
+ void testDependencyResolutionFailure() {
def manager = new DefaultGrailsPluginManager([MyGrailsPlugin] as Class[], ga)
- try {
+ shouldFail(PluginException) {
manager.loadPlugins()
assert !manager.hasGrailsPlugin("my")
}
- catch (PluginException pe) {
- // expected
- }
}
- void testDependencyResolutionSucces() throws Exception {
+ void testDependencyResolutionSucces() {
def manager = new DefaultGrailsPluginManager([MyGrailsPlugin,AnotherGrailsPlugin, SomeOtherGrailsPlugin] as Class[], ga)
manager.loadPlugins()
View
6 ...ls-test-suite-uber/src/test/groovy/org/codehaus/groovy/grails/plugins/PluginDescriptorReaderTests.groovy
@@ -16,7 +16,7 @@ import org.codehaus.groovy.grails.plugins.springsecurity.AuthorizeTools
class FooBarGrailsPlugin {
def version = "0.1"
def grailsVersion = "1.3"
- def evicts = ['hibernate', 'domainClass']
+ def evict = ['hibernate', 'domainClass']
def dependsOn = ['hibernate':'1.3', 'domainClass':'1.2']
}
'''.bytes))
@@ -24,9 +24,9 @@ class FooBarGrailsPlugin {
assert "0.1" == plugin.version : "plugin version should have been 0.1"
assert "foo-bar" == plugin.name : "plugin name should have been 'foo-bar'"
assert "1.3" == plugin.grailsVersion : "grails version should have been '1.2'"
- assertEquals "The full plugin name should be 'foo-bar-0.1'","foo-bar-0.1" ,plugin.fullName
+ assertEquals "The full plugin name should be 'foo-bar-0.1'", "foo-bar-0.1", plugin.fullName
- assertEquals(['hibernate', 'domainClass'], plugin.evicts)
+ assertEquals(['hibernate', 'domainClass'], plugin.evict)
assertEquals(['hibernate':'1.3', 'domainClass':'1.2'], plugin.dependsOn)
assertEquals 5, plugin.properties.size()
View
3  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/GrailsDispatcherServlet.java
@@ -462,8 +462,7 @@ public Locale getLocale() {
protected HttpServletResponse useWrappedOrOriginalResponse(HttpServletResponse response) {
HttpServletResponse r = WrappedResponseHolder.getWrappedResponse();
- if (r != null) return r;
- return response;
+ return r == null ? response : r;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
View
23 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/AbstractGrailsControllerHelper.java
@@ -18,7 +18,18 @@
import groovy.lang.Closure;
import groovy.lang.GroovyObject;
import groovy.util.Proxy;
-import org.apache.commons.beanutils.BeanMap;
+
+import java.io.IOException;
+import java.security.AccessControlException;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.collections.map.CompositeMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -42,16 +53,6 @@
import org.springframework.web.context.ServletContextAware;
import org.springframework.web.servlet.ModelAndView;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.security.AccessControlException;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
/**
* Processes Grails controller requests and responses.
*
View
14 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/servlet/mvc/GrailsControllerBeanMap.java
@@ -16,14 +16,13 @@
package org.codehaus.groovy.grails.web.servlet.mvc;
import grails.web.Action;
-import org.apache.commons.beanutils.BeanMap;
-import org.apache.commons.collections.keyvalue.AbstractMapEntry;
import java.lang.reflect.Method;
-import java.util.Iterator;
+
+import org.apache.commons.beanutils.BeanMap;
/**
- * Filter action getters
+ * Filter action getters.
*
* @author Stephane Maldini
* @since 2.0
@@ -37,10 +36,9 @@ public GrailsControllerBeanMap(Object bean) {
@Override
public Object get(Object name) {
Method method = getReadMethod(name);
- if (method.getAnnotation(Action.class) != null)
- return null;
- else
+ if (method.getAnnotation(Action.class) == null) {
return super.get(name);
+ }
+ return null;
}
-
}
View
6 grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/GroovyPageTagBody.java
@@ -65,7 +65,7 @@ private Object captureClosureOutput(Object args, boolean hasArgument) {
Object bodyResult;
- if(hasArgument) {
+ if (hasArgument) {
originalIt = saveItVariable(currentBinding, args);
}
@@ -140,11 +140,11 @@ private void restoreItVariable(Binding currentBinding, Object originalIt) {
@SuppressWarnings("unchecked")
private Map<String,Object> addAndSaveVariables(Binding binding, Map args) {
Map<String,Object> savedVariablesMap = new LinkedHashMap<String,Object>();
- for (Iterator<Object> i = ((Map)args).keySet().iterator(); i.hasNext(); ) {
+ for (Iterator<Object> i = args.keySet().iterator(); i.hasNext(); ) {
String varname = String.valueOf(i.next());
savedVariablesMap.put(varname, binding.getVariable(varname));
}
- if(binding instanceof GroovyPageBinding) {
+ if (binding instanceof GroovyPageBinding) {
((GroovyPageBinding)binding).addMap(args);
} else {
for (Iterator<Map.Entry> i = args.entrySet().iterator(); i.hasNext(); ) {
View
2  grails-web/src/main/groovy/org/codehaus/groovy/grails/web/taglib/LayoutWriterStack.java
@@ -71,7 +71,7 @@ public static Writer currentWriter(String name) {
* @param body the body closure of the calling "layout" tag
* @return a Map that contains the results of all the parts in the body and the body itself
*/
- public static Map<String, Object> writeParts(Closure body) {
+ public static Map<String, Object> writeParts(Closure<?> body) {
LayoutWriterStack stack = LayoutWriterStack.currentStack();
stack.push();
Map<String, Object> result = new HashMap<String, Object>();
View
2  settings.gradle
@@ -29,7 +29,7 @@ include 'grails-bootstrap',
'grails-plugin-scaffolding',
'grails-plugin-testing',
'grails-plugin-tomcat',
- 'grails-plugin-async',
+ 'grails-plugin-async',
// Test Suite
'grails-test-suite-base',
Please sign in to comment.
Something went wrong with that request. Please try again.