db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sunitha Kambhampati (JIRA)" <derby-...@db.apache.org>
Subject [jira] Commented: (DERBY-1466) Network Server should flush the PrintWriter after console output
Date Thu, 13 Jul 2006 22:09:30 GMT
    [ http://issues.apache.org/jira/browse/DERBY-1466?page=comments#action_12420949 ] 

Sunitha Kambhampati commented on DERBY-1466:
--------------------------------------------

I took a quick look at this and want to  start a discussion on how this could be solved. 

Per java api for PrintWriter
-- There is no method to turn autoflush on an existing PrintWriter object.
-- when autoflush is on, flush will happen on the println statement only.

some solution options:
1) one is wrap the user's writer object with a PrintWriter and set autoflush to true
    -- change in code only required in two places.
    -- maybe ugly to wrap the object.

2)  explicitly call flush in all places after  we write to this writer object.
 
In Eclipse, searched for places where the logWriter in NetworkServerControl is referenced,
here is the list
NetworkServerControlImpl - org.apache.derby.impl.drda - java/drda - ks_trunk
consoleExceptionPrintTrace(Throwable) (3 potential matches)
consoleMessage(String) (3 potential matches)
executeWork(String[]) (potential match)
setLogWriter(PrintWriter) (potential match)
shutdown() (2 potential matches)

So that is not a lot of places. so option 2 should be simple too. unless we miss to call flush
in all the places.
------------------

There is one case where the writer is passed to exception.printStackTrace . If this gets flushed
correctly in autoflush mode, I think #1 seems ok to me, less number of changes than #2.

I  was concerned a bit if setting autoflush will have any performance impact.  But maybe it
is ok since console output is not expected to be verbose anyways.

Comments/thoughts ?

Thanks.

> Network Server should flush the PrintWriter after console output
> ----------------------------------------------------------------
>
>          Key: DERBY-1466
>          URL: http://issues.apache.org/jira/browse/DERBY-1466
>      Project: Derby
>         Type: Improvement

>   Components: Network Server
>     Versions: 10.1.2.1
>     Reporter: Kathey Marsden

>
> If Network Server is started with a PrintWriter specified for console output it will
not automatically flush output such as  starting the server.  This can be confusing as the
console output shows no activity.
> Users currently need to specify the PrintWriter to autoflush  e.g.
>  starterWriter = new PrintWriter(new FileOutputStream(new File(SERVER_START_LOG)),true);

> derbyServer = new NetworkServerControl();
>  derbyServer.start(starterWriter); 
> For repro see:
> http://www.nabble.com/Questions-about-Network-Server-API-Behavior-p5055814.html
> And change the following line in the program to not autoflush as follows:
> starterWriter = new PrintWriter(new FileOutputStream(new File(SERVER_START_LOG)),false);


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


Mime
View raw message