You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2017/11/23 03:02:37 UTC
[2/2] groovy git commit: minor refactor
minor refactor
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/8e2e942f
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/8e2e942f
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/8e2e942f
Branch: refs/heads/GROOVY_2_5_X
Commit: 8e2e942fea6511ddb87a9927b73cd7c27ce3c0bb
Parents: e28d031
Author: paulk <pa...@asert.com.au>
Authored: Thu Nov 23 07:55:06 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Nov 23 13:02:13 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/8e2e942f/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/8e2e942f/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/8e2e942f/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
}
}