Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7717187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:49:24+00:00 2026-06-01T02:49:24+00:00

I just added an ExecutionHandler to my server pipeline just before my main business

  • 0

I just added an ExecutionHandler to my server pipeline just before my main business logic handler as recommended in the documentation.

I am using Apache Shiro http://shiro.apache.org/ for security. It worked fine until I added the ExecutionHandler.

The issue:
Shiro’s execution context is bound to the current thread in which you obtain the Subject object. So, if the Subject is obtained in the worker thread, but the business logic executes in a separate ExecutionHandler managed thread then the two execution contexts won’t be connected as far as Shiro is concerned. Thus Shiro in the ExecutionHandler thread will fail to be aware that the Subject is in fact authenticated. So I’m getting Authentication errors.

It is possible to associate a given Subject with a Runnable before passing it to Executor.execute() so that the security context is maintained. See: http://shiro.apache.org/subject.html

Based on this I think need to find a way to associate the current Shiro Subject with the ExecutionHandler Runnable.

I’m still trying to fully understand the ExecutionHandler and OrderedMemoryAwareThreadPoolExecutor implementations.

Basically I need to call subject.associateWith(aRunnable) just before aRunnable is passed to Executor.execute(aRunnable).

Does anyone have thoughts on where/how I could hook Shiro into the mix?

Thanks,
Matt

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T02:49:26+00:00Added an answer on June 1, 2026 at 2:49 am

    Shiro can automate the thread handoffs for you.

    You should be able to just use one of the SubjectAwareExecutor, SubjectAwareExecutorService, or SubjectAwareScheduledExecutorService implementations out of the box. You can wrap the actual ExecutorService that will execute the Runnables, and you’re good. For example:

    ExecutorService myExistingExecutorService = //get from somewhere
    ExecutorService useThis = new SubjectAwareExecutorService(myExistingExecutorService);
    

    You can ‘inject’ or configure the useThis instance anywhere in your application and the calling code doesn’t ever need to know Shiro exists.

    For example, an unaware component calling useThis.submit(someRandomRunnable) has no idea that Shiro is in use, but the Shiro Subject will still be retained across threads. Check out the respective JavaDoc pages for more.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just added xUnit to our test project (for the Asserts, we're still using
I just added printing capability to a web site using a style sheet (ie.
I just added this to my web.xml on my JBOSS server. But it had
I just added a UIDatePicker to my iPad app using IB, linked it to
I just added OpenID to my website using the PHP janrain libraries, and I
I just added users to my application using devise, and everything is working fine.
I just added 3 applications to my page using: https://www.facebook.com/dialog/pagetab?app_id=[appid]&next=[siteurl] That all works fine,
i just added a ADBannerView to my view using interface builder. There was no
I just added the EGODatabase for using SQLite in my project. I created a
I have just added a linked library to my project using the question here

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.