[Quickfix-developers] Java methods setString() etc. should catch null values
Brought to you by:
orenmnero
From: Joerg T. <Joe...@ma...> - 2003-04-25 15:33:03
|
Hi Oren, if I set a String field with a Java null value, this is handed through to the C++ code as a NULL pointer. Here it leads to core dumps... 152 JNIEXPORT void JNICALL Java_org_quickfix_Message_setString0 153 ( JNIEnv *pEnv, jobject obj, jint field, jstring value ) 154 { QF_STACK_TRY 155 156 JVM::set( pEnv ); 157 FIX::Message* pMessage = getCPPMessage( obj ); 158 setString( *pMessage, field, value ); ^^^^^ = NULL for Java null 159 160 QF_STACK_CATCH 161 } 162 IMHO, all such places where Java nulls could occur should be appropriately handling, eg by throwing a runtime exception java.lang.NullPointerException. This is what Java programmers expect. Most easily the checks could be added into org/quickfix/Message.java: if ( null == value ) { throw new NullPointerException( "...detail message..." ); } 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 |