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 7695313
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:31:11+00:00 2026-05-31T21:31:11+00:00

I have a very strange situation. I´m working on a pretty big Java application

  • 0

I have a very strange situation. I´m working on a pretty big Java application with many bugs, and I found this one today.

I´ll try to explain the situation without posting code because the methods are way too long and I have identified and isolated the specific problem. Here it is:

I have a session attribute set on a Controller class. The attribute has several fields, a couple of Strings, a couple of int and an ArrayList of a certain object type. It is set like this:

request.getSession().setAttribute(Constants.SESSION_LIST_SEARCH, beanList);

Then there is another Controller class where I need to read this attribute, it goes like this:

request.getSession().getAttribute(Constants.SESSION_LIST_SEARCH);

When the controller gets the attribute (with the proper cast) the Strings and the int fields are there, but the ArrayList it´s empty.

I couldn’t find an answer so in an act of desperation I tried to “clone” the list to see what happened, so it goes like this:

request.getSession().setAttribute(Constants.SESSION_LIST_SEARCH, beanList);
/* Desperate developer */
ArrayList<ActivityBean> duplicatedList = new ArrayList<ActivityBean>();
for(ActivityBean foo:beanList.getActivityBean()){
    duplicatedList.add(foo);
}
request.getSession().setAttribute("duplicatedList",duplicatedList);

This workaround does the trick (now I can read the bean “duplicatedList” from the session correctly) but it just doesn’t seem right that the original bean loses the ArrayList on some point and still maintain the other fields.

Thanks in advance

  • 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-05-31T21:31:12+00:00Added an answer on May 31, 2026 at 9:31 pm

    It seems that somewhere else in your application, some code is modifying the List (since you said that it’s not null but empty – if it was null I’d expect that it was removed from context at all by some other part of code). Maybe after putting List to the context some code still maintains reference and operates on it?

    You can try to do the following:

    request.getSession().setAttribute(Constants.SESSION_LIST_SEARCH, Collections.unmodifiableList(beanList));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very strange situation. I have a large set of records to
We have very strange problem, one of our applications is continually querying server by
We have encountered a very strange class not found problem in our web app
I have faced a very strange situation here. I am accessing database (MDB) through
Very strange situation. check this out : billy@prog:~/sql$ grep -R temp_exchange *.sp billy@prog:~/sql$ grep
I have a very strange case where my Module is working but my Module's
I have a pretty weird situation here, and i came up with a very
I have a very strange situation happening and I'm hoping someone here knows why.
I have a very strange situation. Basically I have code that uses a decryptor
a noob question here. I have a very strange situation that's very puzzling to

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.