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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:54:23+00:00 2026-06-09T12:54:23+00:00

Recently while doing some work with C# & ActiveMQ (via the Apache.NMS libraryies) I

  • 0

Recently while doing some work with C# & ActiveMQ (via the Apache.NMS libraryies) I came across the following property on the ActiveMQBytesMessage

public new byte[] Content
{
  get
  {
    byte[] buffer = (byte[]) null;
    this.InitializeReading();
    if (this.length != 0)
    {
      buffer = new byte[this.length];
      this.dataIn.Read(buffer, 0, buffer.Length);
    }
    return buffer;
  }
  ..(setter omitted)
}

The InitialiseReading method handled the connection & streaming of the data from active MQ into the .dataIn field. The problem though was that IT DID THIS EVERYTIME. And once that data was read, it could never be read again and the dataIn field was zero’d and reset. So simply by observing the property and observing it again, you lost the data. This made for some very strange bugs such as:

byte [] myBytes = new byte[msg.Content.Length]; 
//Touched the property. Data read in.

msg.Content.CopyTo(myBytes,0); 
//Uh oh! touched it again, copying a zero'd array.

or when you were debugging and you stuck a watch variable on the property or accidentally hovered your mouse over the property.

Is this kind of mechanism an accepted or prevalent way of using properties for streamed data.

  • 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-09T12:54:25+00:00Added an answer on June 9, 2026 at 12:54 pm

    Very very poor code.

    The general wisdom is that properties should not affect the inner state of an object. If you call set, then get you should always get back the value you’ve just set. If you call get twicwe, you should get the same result twice.

    This should have been a method called GetContent at very least, but id still expect to be able to call that method repeatedly and get the same result.

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

Sidebar

Related Questions

I have been using GQuery for a while now. I recently came across some
recently, while working on a db2 -> oracle migration project, we came across this
So I was recently doing some work, when somebody told me that if doing
I've been doing some pagination recently and used the following: if ( $totalPages >
While working on a script recently, I came across a peculiar nuance of how
I was working on some code recently and came across a method that had
Recently, while reading a Socket Programming HOWTO the following section jumped out at me:
I've been doing lots of work recently on the new Workflow 4.0. One of
I have recently been doing some circle detection in OpenCV and I have had
This is an issue that recently came up for me while writing a new

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.