0

我有下面的课程来检查传入的请求。

public class SecuredAction extends Action.Simple 
{  


    @Override
    public Promise<Result> call(Context ctx) throws Throwable 
    {
        // Not doing anything now. Just interrupting it
        return delegate.call(ctx);
    }
}

我正在将它应用到另一个控制器上,比如

@With(SecuredAction.class) 
public class TestController extends BasicController {
public Result method1(){}
public Result method2(){}
--
}

问题是,如果来自浏览器的多个请求,请求被破坏/响应被混淆。在上述情况下,当 @With(SecuredAction.class) 时,对方法 1 和方法 2 的调用仅通过其中一个用来。如果删除此注释,我不会看到此问题。它与上下文有关吗?它不是读安全的吗?正确的做法是什么?请问有什么帮助吗?

4

1 回答 1

2

看起来将 SecuredAction 设为非单例(@Scope("prototype") )可以解决问题。之后就再也看不到这个问题了。

这意味着委托在传入请求/线程不安全之间共享。

于 2015-07-14T10:00:59.320 回答