groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject groovy git commit: minor refactor
Date Thu, 23 Nov 2017 03:04:06 GMT
Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X 4955c999b -> 6f4503471


minor refactor


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/6f450347
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/6f450347
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/6f450347

Branch: refs/heads/GROOVY_2_4_X
Commit: 6f45034719d0f4ee57b33d0cb669a5d28268b264
Parents: 4955c99
Author: paulk <paulk@asert.com.au>
Authored: Thu Nov 23 07:55:06 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Thu Nov 23 13:03:51 2017 +1000

----------------------------------------------------------------------
 gradle/pomconfigurer.gradle                     |  3 ++
 .../groovy/jmx/builder/JmxTimerFactory.groovy   | 56 ++++++++++----------
 .../jmx/builder/JmxTimerFactoryTest.groovy      |  3 --
 3 files changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/6f450347/gradle/pomconfigurer.gradle
----------------------------------------------------------------------
diff --git a/gradle/pomconfigurer.gradle b/gradle/pomconfigurer.gradle
index 197dc42..07e38db 100644
--- a/gradle/pomconfigurer.gradle
+++ b/gradle/pomconfigurer.gradle
@@ -588,6 +588,9 @@ project.ext.pomConfigureClosureWithoutTweaks = {
             contributor {
                 name 'Stephane Landelle'
             }
+            contributor {
+                name 'Vladimir Vivien'
+            }
         }
         mailingLists {
             mailingList {

http://git-wip-us.apache.org/repos/asf/groovy/blob/6f450347/subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxTimerFactory.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxTimerFactory.groovy
b/subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxTimerFactory.groovy
index 934ead2..6b51bf7 100644
--- a/subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxTimerFactory.groovy
+++ b/subprojects/groovy-jmx/src/main/groovy/groovy/jmx/builder/JmxTimerFactory.groovy
@@ -39,8 +39,6 @@ import javax.management.ObjectName
  *     occurences:long
  * )
  * </pre>
- *
- * @author Vladimir Vivien
  */
 class JmxTimerFactory extends AbstractFactory {
     public Object newInstance(FactoryBuilderSupport builder, Object nodeName, Object nodeParam,
Map nodeAttribs) {
@@ -67,10 +65,10 @@ class JmxTimerFactory extends AbstractFactory {
         metaMap.listeners = getNormalizedRecipientList(metaMap.listeners)
 
         def result = registerTimer(metaMap)
-        return result
+        result
     }
 
-    private def getNormalizedName(fsb, timer, name) {
+    private static getNormalizedName(fsb, timer, name) {
         def result
         if (!name) {
             result = getDefaultName(fsb, timer)
@@ -80,18 +78,18 @@ class JmxTimerFactory extends AbstractFactory {
             } else if (name instanceof ObjectName) {
                 result = name
             } else {
-                result = getDefaultName(fsb, time)
+                result = getDefaultName(fsb, timer)
             }
         }
-        return result
+        result
     }
 
-    private def getDefaultName(fsb, timer) {
+    private static getDefaultName(fsb, timer) {
         def name = "${fsb.getDefaultJmxNameDomain()}:type=TimerService,name=Timer@${timer.hashCode()}"
-        return new ObjectName(name)
+        new ObjectName(name)
     }
 
-    private def getNormalizedDate(date) {
+    private static getNormalizedDate(date) {
         if (!date) return new Date()
         if (date instanceof Date) {
             return date
@@ -103,10 +101,10 @@ class JmxTimerFactory extends AbstractFactory {
             default:
                 startDate = new Date()
         }
-        return startDate
+        startDate
     }
 
-    private def getNormalizedPeriod(period) {
+    private static getNormalizedPeriod(period) {
         if (!period) return 1000L
         if (period instanceof Number) {
             return period
@@ -117,8 +115,9 @@ class JmxTimerFactory extends AbstractFactory {
             def value
             try {
                 value = period[0..-2].toLong()
-            } catch (e) {
+            } catch (ignore) {
                 multiplier = "x"
+                value = 0
             }
             switch (multiplier) {
                 case "s":
@@ -137,28 +136,29 @@ class JmxTimerFactory extends AbstractFactory {
                     result = 1000L
             }
         }
-        return result
+        result
     }
 
-    private def getNormalizedRecipientList(list) {
+    private static getNormalizedRecipientList(list) {
         if (!list) return null
         def result = []
 
-        list.each {name ->
+        list.each { name ->
             def on
             if (name instanceof String) {
                 on = new ObjectName(name)
-            }
-            if (name instanceof ObjectName) {
+            } else if (name instanceof ObjectName) {
                 on = name
+            } else {
+                on = new ObjectName(name.toString())
             }
             result.add(on)
         }
 
-        return result
+        result
     }
 
-    private def registerTimer(metaMap) {
+    private static registerTimer(metaMap) {
         def server = (MBeanServer) metaMap.server
         def timer = metaMap.timer
         timer.addNotification(
@@ -173,26 +173,26 @@ class JmxTimerFactory extends AbstractFactory {
             server.unregisterMBean metaMap.name
         }
         server.registerMBean(timer, metaMap.name)
-        return new GroovyMBean(metaMap.server, metaMap.name)
+        new GroovyMBean(metaMap.server, metaMap.name)
     }
 
-    private NotificationFilter getEventFilter(type) {
+    private static NotificationFilter getEventFilter(type) {
         def noteFilter = new NotificationFilterSupport()
         noteFilter.enableType type
-        return noteFilter
+        noteFilter
     }
 
-    public boolean onHandleNodeAttributes(FactoryBuilderSupport builder, Object node, Map
nodeAttribs) {
-        return false;
+    boolean onHandleNodeAttributes(FactoryBuilderSupport builder, Object node, Map nodeAttribs)
{
+        false
     }
 
-    public boolean isLeaf() {
-        return true;
+    boolean isLeaf() {
+        true
     }
 
-    public void onNodeCompleted(FactoryBuilderSupport builder, Object parentNode, Object
thisNode) {
+    void onNodeCompleted(FactoryBuilderSupport builder, Object parentNode, Object thisNode)
{
         if (parentNode != null) {
             parentNode.add(thisNode)
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/groovy/blob/6f450347/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxTimerFactoryTest.groovy
----------------------------------------------------------------------
diff --git a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxTimerFactoryTest.groovy
b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxTimerFactoryTest.groovy
index 59c6496..1a8a6dc 100644
--- a/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxTimerFactoryTest.groovy
+++ b/subprojects/groovy-jmx/src/test/groovy/groovy/jmx/builder/JmxTimerFactoryTest.groovy
@@ -135,9 +135,6 @@ class JmxTimerFactoryTest extends GroovyTestCase {
         shouldFail {
             timer = builder.timer(period: "2d")
             assert timer.getPeriod(1) == (22000 * 60 * 60)
-
-            timer = builder.timer(period: "Mood")
-            assert timer.getPeriod(1) == 0
         }
     }
 


Mime
View raw message