Re: [Quickfix-developers] fatal error in java api.
Brought to you by:
orenmnero
From: Joerg T. <Joe...@ma...> - 2004-11-03 09:37:15
|
Hi Andrew, > Hello.. This bit of code where I set the null value... > > quickfix.fix41.OrderCancelRequest message = > new quickfix.fix41.OrderCancelRequest > (new OrigClOrdID("1"), > new ClOrdID("2"), > new Symbol("MSFT"), > new Side(Side.BUY)); > > message.setString(100, null); > > causes this.. > > Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at Actually, the JNI layer code should check for NULL values and throw a java.lang.NullPointerException. This a bit more polite than crashing with a Segmentation Violation, but anyway: you should not set a field to "null." What result would you expect? Looking at src/java/Conversions.h: 136 inline void setString( FIX::FieldMap& map, jint field, jstring value ) 137 { 138 const char* uvalue = ENV::get()->GetStringUTFChars( value, 0 ); 139 map.setField( field, uvalue ); 140 ENV::get()->ReleaseStringUTFChars( value, uvalue ); 141 } Between lines 138 and 139 a check whether uvalue is NULL should be inserted: 138a if ( NULL == uvalue ) { 138b return; 138c } In this case, GetStringUTFChars() has already thrown an exception, so it is not necessary to throw a new one. This is the default idiom in JNI. I still have to check whether this also cares for java null values, i.e. whether GetStringsUTF() also checks for a jstring null value. I submitted a bug report on the QuickFIX bugtracker: http://www.quickfixengine.org/bugtracker/bug.php?op=show&bugid=27 Cheers, Jörg -- Joerg Thoennes http://macd.com Tel.: +49 (0)241 44597-24 Macdonald Associates GmbH Fax : +49 (0)241 44597-10 Lothringer Str. 52, D-52070 Aachen |