On 26/07/16 04:24, Frank Yuan wrote:
Thank you very much for your suggestions! Now I fully understand the rule(at 
least I think so :P)
I will use a runWithAllPerm block surrounding the user setup code as Daniel's 
way. Btw, Daniel, ThreadLocal should not need Atomic
any more, correct?


Hi Frank,

runWithAllPerm is another way to do it.
It uses a ThreadLocal<Permissions>, right?

I agree it's adequate. Just be careful of what might
happen if you run runWithAllPerm inside runWithPermissions,
or runWithPermissions(runnable, a,b,c) with a runnable that
later calls runWithPermission(runnable2, a, d, e) further down
the road.

At the moment I'm not sure whether your code will work correctly
in the presence of such nested invocation (maybe it does),
but because it seems to be index based it's not immediately
obvious (I'm not asking you to change it - just to verify and
confirm that it's something you have taken into account, and
that you're confident that it works).


Best regards,

-- daniel

Reply via email to