db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From TomohitoNakayama <tomon...@basil.ocn.ne.jp>
Subject Re: [jira] Updated: (DERBY-326) Improve streaming of large objects for network server and client
Date Fri, 06 Jan 2006 12:15:29 GMT
Hello.
Daniel and David.

Thank you.
Two of your comments recalled me use of SanityManager.

The modifications shown in next are relating part of the new patch.

First part:
+        if(SanityManager.DEBUG){
+        SanityManager.ASSERT( blob != null ||
+                      clob != null,
+                      "Either blob or clob must be non-null.");
+        }
+
+        if(blob != null){
+        is = blob.getBinaryStream();
+       
+        }else if(clob != null){
+        is = new ReEncodedInputStream(clob.getCharacterStream(),
+                          NetworkServerControlImpl.DEFAULT_ENCODING);

Second part:
+    public ReEncodedInputStream(Reader reader,String enc)
+    throws UnsupportedEncodingException,
+           IOException {
+   
+    if(SanityManager.DEBUG){
+        SanityManager.ASSERT( reader != null,
+                  "null 'reader' passed to ReEncodedInputStream" );
+        SanityManager.ASSERT( enc != null,
+                  "null 'encoding' passed to ReEncodedInputStream" );
+    }
+   
+    reader_ = reader;
+    enc_ = enc;
+    buffer_ = reEncode(reader_,
+               enc,
+               BUFFERED_CHAR_LEN);
+   
+    }

Using SanityManager, overhead of tests can be removed.
Furthermore, placing these testing code as not used in usual operation,
it is not necessary for these messages to be internationalized.

// I knew name of assert, however, I have not used it ever.
// This was good experience for me :)


Best regards.


Daniel John Debrunner wrote:

>David W. Van Couvering wrote:
>
>  
>
>>Bryan Pendleton wrote:
>>
>>    
>>
>>>2) It seems like it might be possible to improve these lines in
>>>   ReEncodedInputStream.java:
>>>
>>>        if(reader == null){
>>>            throw new NullPointerException();
>>>        }
>>>
>>>        if(enc == null){
>>>            throw new NullPointerException();
>>>        }
>>>
>>>   I think it would be better to pass a string to the exception
>>>   constructor, indicating which variable was null, as in:
>>>
>>>            throw new NullPointerException(
>>>                "null 'reader' passed to ReEncodedInputStream");
>>>      
>>>
>
>Actually, I'd be interested to know why such tests are required? Why is
>there a need to throw a NPE if a parameter or variable is null?
>
>It's not a coding style I like.
>
>Dan.
>
>
>
>  
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Mime
View raw message