harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sean Qiu (JIRA)" <j...@apache.org>
Subject [jira] Closed: (HARMONY-5981) [classlib][logging] FileHandler may throw exception when logging to the same file by multiple thread
Date Wed, 08 Jul 2009 09:14:14 GMT

     [ https://issues.apache.org/jira/browse/HARMONY-5981?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Sean Qiu closed HARMONY-5981.
-----------------------------


Close this pending issue.

> [classlib][logging] FileHandler may throw exception when logging to the same file by
multiple thread
> ----------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-5981
>                 URL: https://issues.apache.org/jira/browse/HARMONY-5981
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>    Affects Versions: 5.0M7
>            Reporter: Sean Qiu
>            Assignee: Sean Qiu
>             Fix For: 5.0M11
>
>         Attachments: HARMONY-5981.diff
>
>
> When we are trying to log by a Filehandler to publish the information into a same file,it
will introduce multi-thread defect .
> As a result, it will throw such exception[1] while logging. 
> The root cause is that the destination file may be deleted by other thread if they are
not synchronized.
> Below testcase[2] can reproduce the issue.
> [1]
> java.util.logging.ErrorManager: WRITE_FAILURE
> Error message - Exception occurred when writing to the output stream.
> Exception - java.io.IOException: Writer is closed.
> [2]
> package logging;
> import java.io.File;
> import java.util.logging.FileHandler;
> import java.util.logging.Logger;
> public class FileHandlerTest {
>     static class LoggingThread implements Runnable {
>         private Logger logger;
>         
>         public LoggingThread(Logger logger){
>             this.logger = logger;
>         }
>         public void run() {
>             while (true) {
>                 logger.info("Test");
>             }
>         }
>     }
>     public static void main(String[] args) throws Exception {
>         Logger logger = Logger.getLogger("test");
>         String path = new File(".").getAbsolutePath();
>         FileHandler fh = new FileHandler(path, 3000000, 12, false);
>         logger.setUseParentHandlers(false);
>         logger.addHandler(fh);
>         Thread[] threads = new Thread[12];
>         for (Thread thread : threads) {
>             thread = new Thread(new LoggingThread(logger));
>             thread.start();
>         }
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message