You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by GitBox <gi...@apache.org> on 2018/10/01 16:29:00 UTC

[GitHub] oscerd closed pull request #144: chore: small improvement to groovy dls

oscerd closed pull request #144: chore: small improvement to groovy dls
URL: https://github.com/apache/camel-k/pull/144
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/runtime/groovy/src/main/java/org/apache/camel/k/groovy/GroovyRoutesLoader.java b/runtime/groovy/src/main/java/org/apache/camel/k/groovy/GroovyRoutesLoader.java
index 125cd26..6b7beed 100644
--- a/runtime/groovy/src/main/java/org/apache/camel/k/groovy/GroovyRoutesLoader.java
+++ b/runtime/groovy/src/main/java/org/apache/camel/k/groovy/GroovyRoutesLoader.java
@@ -92,15 +92,20 @@ public Component component(String name, Closure<Component> callable) {
             callable.setResolveStrategy(Closure.DELEGATE_ONLY);
             callable.setDelegate(new GroovyObjectSupport() {
                 public Object invokeMethod(String name, Object arg) {
+                    final Object value;
+
                     if (arg == null) {
-                        return super.invokeMethod(name, arg);
-                    }
-                    if (!arg.getClass().isArray()) {
-                        return super.invokeMethod(name, arg);
+                        value = null;
+                    } else if (!arg.getClass().isArray()) {
+                        value = arg;
+                    } else if (Array.getLength(arg) == 1) {
+                        value = Array.get(arg, 0);
+                    } else {
+                        throw new IllegalArgumentException("Unable to set property \"" + name + "\" on component \"" + name + "\"");
                     }
 
                     try {
-                        IntrospectionSupport.setProperty(component, name, Array.get(arg, 0), true);
+                        IntrospectionSupport.setProperty(component, name, value, true);
                     } catch (Exception e) {
                         throw new RuntimeException(e);
                     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services