Commit 5e32f3fe authored by Raphael's avatar Raphael
Browse files

Fixed a bug where the rule avoidThreadGroup would throw an error.

parent af81f962
...@@ -473,7 +473,7 @@ rule measureAvoidThreadGroup(variable : java!VariableDeclarationFragment) { ...@@ -473,7 +473,7 @@ rule measureAvoidThreadGroup(variable : java!VariableDeclarationFragment) {
measure <- noc, measure <- noc,
measurements <- measurement measurements <- measurement
), ),
noc: smm!DimnsionalMeasure ( noc: smm!DimensionalMeasure (
name <- 'Avoid Thread Group', name <- 'Avoid Thread Group',
shortDescription <- 'Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread-safe.' shortDescription <- 'Avoid using java.lang.ThreadGroup; although it is intended to be used in a threaded environment it contains methods that are not thread-safe.'
), ),
......
...@@ -43,23 +43,9 @@ helper def:isDontCallThreadRun(s:java!MethodInvocation): Boolean = ...@@ -43,23 +43,9 @@ helper def:isDontCallThreadRun(s:java!MethodInvocation): Boolean =
--Goes through all the variables to check if the following rule is followed: --Goes through all the variables to check if the following rule is followed:
--Avoid using java.lang.ThreadGroup; --Avoid using java.lang.ThreadGroup;
helper def: avoidThreadGroup() : Set(smm!Measure) = helper def: avoidThreadGroup() : Set(smm!Measure) =
java!VariableDeclarationFragment.allInstances() -> iterate(i; res : Set(smm!Measure) = Set{} | java!VariableDeclarationFragment.allInstances() ->
select(i | i.variablesContainer.type.toString() <> 'OclUndefined')->
if (thisModule.isThreadGroup(i)) select(s|s.variablesContainer.type.type.name.toString() = 'ThreadGroup')->collect(i | thisModule.measureAvoidThreadGroup(i) );
then res->union(Set{thisModule.measureAvoidThreadGroup(i)})
else res
endif
);
--Detect a wrong usage of the variable type java.lang.ThreadGroup
--return true if the variable of type java.lang.ThreadGroup
helper def:isThreadGroup(s:java!VariableDeclarationFragment): Boolean =
if s.variablesContainer.type.type.name.toString() = 'ThreadGroup' then
true
else
false
endif;
--------------------------------------------- UseNotifyAllInsteadOfNotify --------------------------------------------- --------------------------------------------- UseNotifyAllInsteadOfNotify ---------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment