hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Zhanwei Wang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-7207) libhdfs3 should not expose exceptions in public C++ API
Date Mon, 13 Oct 2014 09:03:33 GMT

    [ https://issues.apache.org/jira/browse/HDFS-7207?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14169097#comment-14169097

Zhanwei Wang commented on HDFS-7207:

In my previous patch, InputStream/OutputStream keep a shared_ptr of FileSystemImpl for an
important reason, which is to avoid to use an invalid pointer of FileSystemImpl if the filesystem
is destroyed before InputStream/OutputStream.

DB *db = DB::Open();
Iterator *it = db->(...);
delete db; // bails out because the iterator it has leaked.

This way is good in my opinion, it makes the user to be more aware of the leaks, but a shared_ptr
of DBImpl is still need to keep in Iterator to avoid the core dump if the user continue to
use the iterator after {{delete db}}

> libhdfs3 should not expose exceptions in public C++ API
> -------------------------------------------------------
>                 Key: HDFS-7207
>                 URL: https://issues.apache.org/jira/browse/HDFS-7207
>             Project: Hadoop HDFS
>          Issue Type: Sub-task
>            Reporter: Haohui Mai
>            Assignee: Colin Patrick McCabe
>            Priority: Blocker
>         Attachments: HDFS-7207.001.patch
> There are three major disadvantages of exposing exceptions in the public API:
> * Exposing exceptions in public APIs forces the downstream users to be compiled with
{{-fexceptions}}, which might be infeasible in many use cases.
> * It forces other bindings to properly handle all C++ exceptions, which might be infeasible
especially when the binding is generated by tools like SWIG.
> * It forces the downstream users to properly handle all C++ exceptions, which can be
cumbersome as in certain cases it will lead to undefined behavior (e.g., throwing an exception
in a destructor is undefined.)

This message was sent by Atlassian JIRA

View raw message