You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by ahgittin <gi...@git.apache.org> on 2017/07/22 00:41:27 UTC

[GitHub] brooklyn-server pull request #773: prevent benign error in file deletion shu...

GitHub user ahgittin opened a pull request:

    https://github.com/apache/brooklyn-server/pull/773

    prevent benign error in file deletion shutdown-hook

    - ensure required bundle has been loaded before shutdown
    - fail gracefully if the deletion hook fails

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/ahgittin/brooklyn-server os-logging-for-shutdown

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/brooklyn-server/pull/773.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #773
    
----
commit 6048a5c968236fa997e9b3cd627402012d6d1736
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Date:   2017-07-22T00:39:28Z

    prevent benign error in file deletion shutdown-hook
    
    - ensure required bundle has been loaded before shutdown
    - fail gracefully if the deletion hook fails

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #773: prevent benign error in file deletion shu...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/brooklyn-server/pull/773


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server issue #773: prevent benign error in file deletion shutdown-h...

Posted by ahgittin <gi...@git.apache.org>.
Github user ahgittin commented on the issue:

    https://github.com/apache/brooklyn-server/pull/773
  
    both done, thanks guys.  aled, i added the `, e` as a debug message.
    
    merging.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #773: prevent benign error in file deletion shu...

Posted by aledsage <gi...@git.apache.org>.
Github user aledsage commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/773#discussion_r129102424
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java ---
    @@ -317,21 +318,28 @@ public void run() throws IOException {
         private static final Map<String,FileDeletionHook> deletions = new LinkedHashMap<String, Os.FileDeletionHook>();
         
         private static void addShutdownFileDeletionHook(String path, FileDeletionHook hook) {
    +        // ensure Ordering class is loaded (else shutdown hook will fail as it can't load that class when shutting down)
    +        Ordering.<Integer>natural();
             synchronized (deletions) {
                 if (deletions.isEmpty()) {
                     Thread shutdownHook = new Thread() {
                         @Override
                         public void run() {
    -                        synchronized (deletions) {
    -                            List<String> pathsToDelete = new ArrayList<String>(deletions.keySet());
    -                            Collections.sort(pathsToDelete, Strings.lengthComparator().reverse());
    -                            for (String path: pathsToDelete) {
    -                                try {
    -                                    deletions.remove(path).run();
    -                                } catch (Exception e) {
    -                                    log.warn("Unable to delete '"+path+"' on shutdown: "+e);
    +                        log.debug("Shutting down, deleting: "+deletions);
    +                        try {
    +                            synchronized (deletions) {
    +                                List<String> pathsToDelete = new ArrayList<String>(deletions.keySet());
    +                                Collections.sort(pathsToDelete, Strings.lengthComparator().reverse());
    +                                for (String path: pathsToDelete) {
    +                                    try {
    +                                        deletions.remove(path).run();
    +                                    } catch (Exception e) {
    +                                        log.warn("Unable to delete '"+path+"' on shutdown: "+e);
    +                                    }
                                     }
                                 }
    +                        } catch (Exception e) {
    --- End diff --
    
    I'd prefer to include `, e`, rather than just its toString. For example, if there were an NPE somewhere in the method then we'd only be told that there was an NPE rather than being told its line number etc.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] brooklyn-server pull request #773: prevent benign error in file deletion shu...

Posted by drigodwin <gi...@git.apache.org>.
Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/773#discussion_r129018661
  
    --- Diff: utils/common/src/main/java/org/apache/brooklyn/util/os/Os.java ---
    @@ -317,21 +318,28 @@ public void run() throws IOException {
         private static final Map<String,FileDeletionHook> deletions = new LinkedHashMap<String, Os.FileDeletionHook>();
         
         private static void addShutdownFileDeletionHook(String path, FileDeletionHook hook) {
    +        // ensure Ordering class is loaded (else shutdown hook will fail as it can't load that class when shutting down)
    +        Ordering.<Integer>natural();
             synchronized (deletions) {
                 if (deletions.isEmpty()) {
                     Thread shutdownHook = new Thread() {
                         @Override
                         public void run() {
    -                        synchronized (deletions) {
    -                            List<String> pathsToDelete = new ArrayList<String>(deletions.keySet());
    -                            Collections.sort(pathsToDelete, Strings.lengthComparator().reverse());
    -                            for (String path: pathsToDelete) {
    -                                try {
    -                                    deletions.remove(path).run();
    -                                } catch (Exception e) {
    -                                    log.warn("Unable to delete '"+path+"' on shutdown: "+e);
    +                        log.debug("Shutting down, deleting: "+deletions);
    +                        try {
    +                            synchronized (deletions) {
    +                                List<String> pathsToDelete = new ArrayList<String>(deletions.keySet());
    +                                Collections.sort(pathsToDelete, Strings.lengthComparator().reverse());
    +                                for (String path: pathsToDelete) {
    +                                    try {
    +                                        deletions.remove(path).run();
    +                                    } catch (Exception e) {
    +                                        log.warn("Unable to delete '"+path+"' on shutdown: "+e);
    +                                    }
                                     }
                                 }
    +                        } catch (Exception e) {
    +                            log.warn("Unable to delete one or mort paths ("+deletions+") on shutdown: "+e);
    --- End diff --
    
    mort -> more


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---