Writer error

9 posts / 0 new
Last post
Offline
Last seen: 7 years 8 months ago
Joined: 07/26/2016
Posts: 6
Writer error

Hi,

 

I get the error below when trying to write -   Writer.write(instance, ref instance_handle);

What is the problem?

PRESWriterHistoryDriver_initializeSample:!serialize
WriterHistoryMemoryPlugin_addEntryToSessions:!initialize sample
WriterHistoryMemoryPlugin_getEntry:!add virtual sample to sessions
WriterHistoryMemoryPlugin_addSample:!get entry
PRESWriterHistoryDriver_addWrite:!add_sample
PRESPsWriter_writeInternal:!collator addWrite
write error DDS.Retcode_Error:
 PRESWriterHistoryDriver_initializeSample:!serialize
  WriterHistoryMemoryPlugin_addEntryToSessions:!initialize sample
   WriterHistoryMemoryPlugin_getEntry:!add virtual sample to sessions
    WriterHistoryMemoryPlugin_addSample:!get entry
     PRESWriterHistoryDriver_addWrite:!add_sample
      PRESPsWriter_writeInternal:!collator addWrite
 
 
Thank
 
Offline
Last seen: 6 days 17 hours ago
Joined: 04/02/2013
Posts: 195

Hi,

You could be setting an illegal value in the sample you're trying to publish. Can you share the type you're publishing or narrow down the potential problem by setting one  field at a time, and publishing that sample until write() fails?

Alex

 

Offline
Last seen: 7 years 8 months ago
Joined: 07/26/2016
Posts: 6

Hi,

I see it's happened when I send null for string field. if I send empty string - "", the error does not happen.
But I don't think it's the right way - to send empty string instead of null.

struct MyType{ 

long Id; //@key
string Name;

};

Thank

Offline
Last seen: 3 months 6 days ago
Joined: 02/11/2016
Posts: 144

Hey,

As far as I'm aware, null values are only supported for fields which are set to be Optional (and I believe it only works if you set mutable extensibility).

Otherwise you can use a workaround:

1. determine "null" values and wrap the entities you've generated with a class which sets null values of entites before you send them (and then you'll need to identify null values receievd by the readers).

2. use a Sequence of length 1 and wrap the entities you've generated with a class which sends an empty sequence for fields that aren't initialized or sequences containing the 1 value that was set for a field (again, you'll need to unwrap the entities you read)

3. some other workaround I'm not familiar with

 

Roy.

Offline
Last seen: 6 days 17 hours ago
Joined: 04/02/2013
Posts: 195

Roy's right. If you want to not send a field (that is, write 'null'), you need to make it optional. In your case:

struct MyType{
    long Id; //@key
    string Name; //@Optional
}; 

Optional works with all extensibility kinds (final, extensible, and mutable).

Alex

 

Offline
Last seen: 7 years 8 months ago
Joined: 07/26/2016
Posts: 6

The solution isn't good enough for me. Because
I want send the field always, whether there is value and whether it has null.
I don't want not to send the field.

Thank

Offline
Last seen: 6 days 17 hours ago
Joined: 04/02/2013
Posts: 195

Assuming that both the reader and the writer use the same type, when you don't set an optional member (i.e. make it NULL), the receiving application will also see NULL.

If you write {2, "Hi"} and {3, NULL}, the receiving application will see exactly that: {2, "Hi"} and {3, NULL}. 

 

Offline
Last seen: 7 years 8 months ago
Joined: 07/26/2016
Posts: 6

As I wrote in my question- my problem is -
I don't receive null - it threw the exception 

- "write error DDS.Retcode_Error:"  (see above)

Offline
Last seen: 6 days 17 hours ago
Joined: 04/02/2013
Posts: 195

Did you add "//@Optional" after "string Name;" ?

struct MyType{
    long Id; //@key
    string Name; //@Optional
};