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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:01:17+00:00 2026-05-15T02:01:17+00:00

I have a very odd problem. A class property is mysteriously reset between method

  • 0

I have a very odd problem.

A class property is mysteriously reset between method calls.

The following code is executed so the constructor is called, then the parseConfiguration method is called. Finally, processData is called.

The parseConfiguration method sets the “recursive” property to “true”. However, as soon as it enters “processData”, “recursive” becomes “false”.

This problem isn’t isolated to a single class — I have several examples of this in my code.

How can this possibly be happening? I’ve tried initialising properties when they’re declared outside any methods, I’ve tried initialising them in constructors… nothing works.

The only complication I can think of here is that this class is invoked by an object that runs in a thread — but here is one instance per thread, so surely no chance that threads are interfering. I’ve tried setting both methods to “synchronized”, but this still happens.

I’m on JDK 1.6.0_19 on linux.

Please help!

/**
 * This class or its superclasses are NOT threaded and don't extend Thread
 */
public class DirectoryAcquirer extends Manipulator
{
/**
 * @var Whether to recursively scan directories
 */
private boolean recursive = false;

/**
 * Constructor
 */
public DirectoryAcquirer()
{
}

/**
 * Constructor that initialises the configuration
 *
 * @param config
 * @throws InvalidConfigurationException
 */
public DirectoryAcquirer(HierarchicalConfiguration config) throws InvalidConfigurationException
{
    super(config);
}

@Override
protected void parseConfiguration() throws InvalidConfigurationException
{
    // set whether to recurse into directories or not
    if (this.config.containsKey("recursive"))
    {
    // this.recursive gets set to "true" here
        this.recursive = this.config.getBoolean("recursive");

    }
}

@Override
public EntityCollection processData(EntityCollection data)
{
// here this.recursive is "false"
    this.logger.debug("processData: Entered method");
}
}
  • 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-15T02:01:18+00:00Added an answer on May 15, 2026 at 2:01 am

    Thanks for your replies.

    It seems that the problem was related to casting:

    /**
     * 
     */
    public class Manipulator
    {
        // both constructors call parseConfiguration()
    
        protected void parseConfiguration() throws InvalidConfigurationException
        {
          // don't do anything. this is a default method that can optionally be 
          // overridden by subclasses
        }
    }
    

    I was referring in some places to the object as a DirectoryAcquirer, an at other times it was upcast to a Manipulator. I think that this was interfering so the empty parseConfiguration method was called after the child one was called — or something like that.

    Anyway, I made the parseConfiguration method in the superclass abstract, and now it’s fine.

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

Sidebar

Ask A Question

Stats

  • Questions 401k
  • Answers 401k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can get the path of the page currently request… May 15, 2026 at 4:35 am
  • Editorial Team
    Editorial Team added an answer I've used string folder = System.Web.HttpContext.Current != null ? System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,… May 15, 2026 at 4:35 am
  • Editorial Team
    Editorial Team added an answer Did you check the return value from unzip? Error messages… May 15, 2026 at 4:35 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.