Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Very strange behavior in Socket Server

 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a strange bug (Microsoft feature) that is driving me crazy

My application works fine in single user mode, however...

In network mode, I'm using a multi-threaded socket server.

The client portion is a new thread spawned from the GUI, this client thread waits until an object is received from the GUI, wakes up, sends this serialized object to the server via
objectOutputStream.writeObject(message);
objectOutputStream.flush();

The server is waiting (objectInputStream) to read an incomming
message

When the server receives the message from the client, it figures out what type of message (object) this is and calls the corresponding remote data access wrapper method (with said message), which in turn calls the appropriate local data access method, the results from the local data access method are then attached to the message via setters, this message is then sent back to the client.

The issue is this, in the FindRemote class I have a String array inside the class that is initialized when the class in instantiated (from search criteria from the search screen), this FindRemote instance is then sent to the server via the client, (the criteria can be pretty complex), no matter how complex the search criteria, the correct records come back (the first try), on the second and subsequent attempts though, the same records that match the original criteria come back, I attempted to debug by printing out the search criteria before just sending the message to the server (Client objectOutputStream(message) and it is what is expected, on the server side the first time thru right after the objectInputStream the criteria matches what was sent from the client, however and subsequent tries, the client prints out the original search criteria.

I can even go and delete records, and then go back an search again, however the original search criteria still comes up.

I'm going nuts, can anyone out there help?

 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12014
220
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thomas,

Hard to tell from what you have described, and I don't think it is related to the code you have posted.

It sounds like you are doing something in your constructor of your FindRemote class (which will not get called since the instance of FindRemote is not constructed but deserialized) - possibly you could resolve this by overriding the readObject method.

Does that give you a hint?

If not, do you want to post some of the code for the FindRemote class?

Regards, Andrew
 
Thomas Paul Bigbee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks
It turned out to be objectOutputStream.reset();
after the write and flush after writing to the Stream. It drove me crazy for three days. It seems that the original object is sent even if you null it out and create and send a new one (unless you reset the Stream)

Tom
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic