Hi,

thanks for your response.
I changed it.

Julian

Am 01.11.18, 12:30 schrieb "Christofer Dutz" <christofer.d...@c-ware.de>:

    Hi Julian,
    
    I agree that we should throw an exception.
    
    Chris
    
    
    
    Am 31.10.18, 21:25 schrieb "Julian Feinauer" <j.feina...@pragmaticminds.de>:
    
        Hi all,
        
        I found some time today to test and toy around a bit with PLC4X and I 
discovered a behavior which I found weird.
        I had the response from a request which “failed” (Response was 
successful but the Field I wanted was NOT_FOUND).
        So my response.getLong(“…”) returned a “null” and a subsequent implicit 
cast to long finally led to a NPE.
        
        My expected behavior would be an Exception (Runtime Exception).
        Also in the case when I try to fetch a filed which is non-existent.
        Currently we return null in both cases (see snippet from 
DefaultPlcReadResponse):
        
        private BaseDefaultFieldItem getFieldInternal(String name) {
            // If this field doesn't exist, ignore it.
            if (values.get(name) == null) {
                return null;
            }
            if (values.get(name).getKey() != PlcResponseCode.OK) {
                return null;
           }
            return values.get(name).getValue();
        }
        
        I suggest to throw a Runtime Exception in both cases to give a “valid” 
Error Message instead of a NPE which is totally unexpected.
        
        Is this okay for everybody? Or are there any concerns?
        
        Julian
        
        
    
    

Reply via email to