Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Very strange behavior in Socket Server

 
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?

 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • 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
 
Live ordinary life in an extraordinary way. Details embedded in this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic