jCaptcha 线程安全吗?

发布于 2024-10-02 15:34:30 字数 418 浏览 0 评论 0原文

我在一个项目中使用 JCaptcha,并且需要一种无法直接提供的行为。所以我查看了源代码,看看是否可以扩展它以获得我想要的东西,并发现我使用的商店实现(MapCaptchaStore) 使用 HashMap 作为存储。 ..没有同步。

我知道 JCaptcha 不能在集群环境中工作,这不是我的情况,但是同时多个客户端怎么样?商店实现是在外部同步的还是我应该自己推出并确保它正确同步?

蒂亚!

I'm using JCaptcha in a project and needed a behavior that was not directly available. so I looked into the source code to see if I can extend it to obtain what I want and found that the store implementation I use (MapCaptchaStore) uses a HashMap as the store... with no synchronization.

I know JCaptcha does not work in a clustered environment, it is not my case, but how about multiple clients at the same time? Is the store implementation synchronized externally or should I roll my own and make sure it is properly synchronized?

TIA!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

时间你老了 2024-10-09 15:34:30

从 MapCaptchaStore 的阅读源来看,此类不是线程安全的。不过,我并不是 100% 愿意支持这个答案,因为同步可能发生在更高的级别(例如,对 MapCaptchaStore 单个实例的所有访问可能会在另一个对象上同步)。

您可以使用 CaptchaStore 的另一种实现。例如,EhcacheCaptchaStore

Judging by the reading source for MapCaptchaStore, this class is NOT thread-safe. I'm not 100% willing to stand behind this answer though, because synchronisation may be happening at a higher level (eg all accesses to a single instance of MapCaptchaStore may be synchronised on another object).

You could use another implementation of CaptchaStore. For example, EhcacheCaptchaStore

萌能量女王 2024-10-09 15:34:30

验证码存储的基本哈希图实现不同步,这可能会导致一些奇怪的行为。
其他存储是线程安全的,为了简单实现,请使用 FastHashMapCaptchaStore。

Basic hashmap implementation of the captcha store is not synchronized, that could lead to some weird behaviour.
Other stores are thread safe, for a simple implementation use FastHashMapCaptchaStore.

笨死的猪 2024-10-09 15:34:30

我假设这是因为它被设计为与始终具有多个客户端的 Web 应用程序集成。它也是一个验证码框架,因此他们必须经过人类和计算机客户端的测试。

不过,我仍然建议测试它在多线程环境中是否表现正常。

I'm assuming it is because it has been designed to be integrated with web applications which will always have multiple clients. It's also a CAPTCHA framework so they must have tested with both human and computer clients.

However, I would still recommend testing whether it behaves correctly in a multithreaded environment.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文