You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by bo...@apache.org on 2026/04/10 01:06:59 UTC
(grails-core) 03/03: chore: resolve several spotbugs and pmd violations
This is an automated email from the ASF dual-hosted git repository.
borinquenkid pushed a commit to branch 8.0.x-hibernate7-dev
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 34805d24605ae054cca8cd8b4fd987324fc64c80
Author: Walter Duque de Estrada <wb...@mac.com>
AuthorDate: Thu Apr 9 19:25:29 2026 -0500
chore: resolve several spotbugs and pmd violations
---
.../grails/async/factory/AbstractPromiseFactory.groovy | 3 +++
.../grails/async/factory/future/FutureTaskPromise.groovy | 16 ++++++++++------
.../grails/async/factory/gpars/LoggingPoolFactory.groovy | 2 +-
.../groovy/grails/core/DefaultGrailsApplication.java | 2 +-
4 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/grails-async/core/src/main/groovy/grails/async/factory/AbstractPromiseFactory.groovy b/grails-async/core/src/main/groovy/grails/async/factory/AbstractPromiseFactory.groovy
index caf480a3d2..52105467a9 100644
--- a/grails-async/core/src/main/groovy/grails/async/factory/AbstractPromiseFactory.groovy
+++ b/grails-async/core/src/main/groovy/grails/async/factory/AbstractPromiseFactory.groovy
@@ -84,6 +84,9 @@ abstract class AbstractPromiseFactory implements PromiseFactory {
* @see PromiseFactory#createPromise(java.util.List, java.util.List)
*/
<T> Promise<List<T>> createPromise(List<Closure<T>> closures, List<PromiseDecorator> decorators) {
+ if (closures == null) {
+ return new PromiseList<T>()
+ }
List<Closure<T>> decoratedClosures = new ArrayList<Closure<T>>(closures.size())
for (Closure<T> closure : closures) {
decoratedClosures.add(applyDecorators(closure, decorators))
diff --git a/grails-async/core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy b/grails-async/core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy
index 66f7256871..2dcfb58e43 100644
--- a/grails-async/core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy
+++ b/grails-async/core/src/main/groovy/org/grails/async/factory/future/FutureTaskPromise.groovy
@@ -84,9 +84,11 @@ class FutureTaskPromise<T> extends FutureTask<T> implements Promise<T> {
@Override
protected void set(T t) {
super.set(t)
- synchronized (successCallbacks) {
- for (FutureTaskChildPromise callback : successCallbacks) {
- callback.accept(t)
+ if (successCallbacks != null) {
+ synchronized (successCallbacks) {
+ for (FutureTaskChildPromise callback : successCallbacks) {
+ callback.accept(t)
+ }
}
}
}
@@ -94,9 +96,11 @@ class FutureTaskPromise<T> extends FutureTask<T> implements Promise<T> {
@Override
protected void setException(Throwable t) {
super.setException(t)
- synchronized (failureCallbacks) {
- for (FutureTaskChildPromise callback : failureCallbacks) {
- callback.accept(t)
+ if (failureCallbacks != null) {
+ synchronized (failureCallbacks) {
+ for (FutureTaskChildPromise callback : failureCallbacks) {
+ callback.accept(t)
+ }
}
}
}
diff --git a/grails-async/gpars/src/main/groovy/org/grails/async/factory/gpars/LoggingPoolFactory.groovy b/grails-async/gpars/src/main/groovy/org/grails/async/factory/gpars/LoggingPoolFactory.groovy
index 3709b41269..57d269346f 100644
--- a/grails-async/gpars/src/main/groovy/org/grails/async/factory/gpars/LoggingPoolFactory.groovy
+++ b/grails-async/gpars/src/main/groovy/org/grails/async/factory/gpars/LoggingPoolFactory.groovy
@@ -48,7 +48,7 @@ class LoggingPoolFactory implements PoolFactory {
private static final long KEEP_ALIVE_TIME = 10L
public static final Logger LOG = LoggerFactory.getLogger(LoggingPoolFactory)
- public static Method createThreadNameMethod
+ public static final Method createThreadNameMethod
static {
createThreadNameMethod = DefaultPool.getDeclaredMethod('createThreadName')
diff --git a/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java b/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java
index 8d5e708de4..03c349b356 100644
--- a/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java
+++ b/grails-core/src/main/groovy/grails/core/DefaultGrailsApplication.java
@@ -99,7 +99,7 @@ public class DefaultGrailsApplication extends AbstractGrailsApplication implemen
protected static final Pattern GETCLASS_PATTERN = Pattern.compile("(get)(\\w+)Class");
protected Class<?>[] allClasses = new Class[0];
- protected static Log log = LogFactory.getLog(DefaultGrailsApplication.class);
+ protected static final Log log = LogFactory.getLog(DefaultGrailsApplication.class);
protected Set<Class<?>> loadedClasses = new LinkedHashSet<>();
protected ArtefactHandler[] artefactHandlers;