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:36 UTC
[1/2] groovy git commit: trivial refactor (whitespace)
Repository: groovy
Updated Branches:
refs/heads/GROOVY_2_5_X c66da8eeb -> 8e2e942fe
trivial refactor (whitespace)
Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/e28d0310
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/e28d0310
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/e28d0310
Branch: refs/heads/GROOVY_2_5_X
Commit: e28d03102ba673bfdb0a36dfd59221a5a5e240f6
Parents: c66da8e
Author: paulk <pa...@asert.com.au>
Authored: Wed Nov 22 08:00:07 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Thu Nov 23 13:02:12 2017 +1000
----------------------------------------------------------------------
.../groovy/classgen/FinalVariableAnalyzer.java | 28 ++++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/groovy/blob/e28d0310/src/main/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java b/src/main/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
index 8983489..76c4e1f 100644
--- a/src/main/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
+++ b/src/main/org/codehaus/groovy/classgen/FinalVariableAnalyzer.java
@@ -66,7 +66,6 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
this.isFinal = isFinal;
}
-
public VariableState getNext() {
switch (this) {
case is_uninitialized:
@@ -102,11 +101,12 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
private static Variable getTarget(Variable v) {
if (v instanceof VariableExpression) {
Variable t = ((VariableExpression) v).getAccessedVariable();
- if (t==v) return t;
+ if (t == v) return t;
return getTarget(t);
}
return v;
}
+
private Map<Variable, VariableState> popState() {
return assignmentTracker.removeLast();
}
@@ -131,7 +131,7 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
Set<VariableExpression> old = declaredFinalVariables;
declaredFinalVariables = new HashSet<VariableExpression>();
super.visitBlockStatement(block);
- if (callback!=null) {
+ if (callback != null) {
Map<Variable, VariableState> state = getState();
for (VariableExpression declaredFinalVariable : declaredFinalVariables) {
VariableState variableState = state.get(declaredFinalVariable.getAccessedVariable());
@@ -218,7 +218,7 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
Map<Variable, VariableState> state = getState();
Variable key = expression.getAccessedVariable();
VariableState variableState = state.get(key);
- if (variableState==VariableState.is_uninitialized) {
+ if (variableState == VariableState.is_uninitialized) {
variableState = VariableState.is_var;
state.put(key, variableState);
}
@@ -254,16 +254,15 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
VariableState ifValue = ifState.get(var);
VariableState elseValue = elseState.get(var);
// merge if and else values
- VariableState mergedIfElse ;
- mergedIfElse = ifValue!=null
- && elseValue!=null
- && ifValue.isFinal && elseValue.isFinal?VariableState.is_final:VariableState.is_var;
+ VariableState mergedIfElse;
+ mergedIfElse = ifValue != null && ifValue.isFinal
+ && elseValue != null && elseValue.isFinal ? VariableState.is_final : VariableState.is_var;
if (beforeValue == null) {
curState.put(var, mergedIfElse);
} else {
if (beforeValue == VariableState.is_uninitialized) {
curState.put(var, mergedIfElse);
- } else if (ifValue!=null || elseValue!=null) {
+ } else if (ifValue != null || elseValue != null) {
curState.put(var, VariableState.is_var);
}
}
@@ -294,10 +293,10 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
Variable var = entry.getKey();
VariableState afterFinallyState = entry.getValue();
VariableState beforeTryCatchState = beforeTryCatch.get(var);
- if (afterFinallyState==VariableState.is_final
- && beforeTryCatchState !=VariableState.is_final
- && afterTryCatchState.get(var)!=beforeTryCatchState) {
- getState().put(var, beforeTryCatchState==null?VariableState.is_uninitialized:beforeTryCatchState);
+ if (afterFinallyState == VariableState.is_final
+ && beforeTryCatchState != VariableState.is_final
+ && afterTryCatchState.get(var) != beforeTryCatchState) {
+ getState().put(var, beforeTryCatchState == null ? VariableState.is_uninitialized : beforeTryCatchState);
}
}
}
@@ -344,6 +343,7 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
/**
* Callback used whenever a variable is declared as final, but can remain in an uninitialized state
+ *
* @param var the variable detected as potentially uninitialized
*/
void variableNotAlwaysInitialized(VariableExpression var);
@@ -352,7 +352,7 @@ public class FinalVariableAnalyzer extends ClassCodeVisitorSupport {
private static class StateMap extends HashMap<Variable, VariableState> {
@Override
public VariableState get(final Object key) {
- return super.get(getTarget((Variable)key));
+ return super.get(getTarget((Variable) key));
}
@Override
[2/2] groovy git commit: minor refactor
Posted by pa...@apache.org.
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
}
}