From 99bc6cf8c55509ee1cbc42085cbe29f058ccec6e Mon Sep 17 00:00:00 2001
From: "Ricardo M. Ferraz Leal" <ricleal@gmail.com>
Date: Mon, 28 Jan 2019 11:01:29 -0500
Subject: [PATCH] Moved the place where sample closeGroup was called

---
 .../inc/MantidDataHandling/LoadEventNexus.h   | 44 ++++++++++---------
 1 file changed, 24 insertions(+), 20 deletions(-)

diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
index 4536b6cfc1a..6c8dbfbddb6 100644
--- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
+++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h
@@ -638,32 +638,36 @@ void LoadEventNexus::loadEntryMetadata(const std::string &nexusfilename, T WS,
   // appropriate state
   try {
     file.openGroup("sample", "NXsample");
-    if (exists(file, "name")) {
-      file.openData("name");
-      const auto info = file.getInfo();
-      std::string name;
-      if (info.type == ::NeXus::CHAR) {
-        if (info.dims.size() == 1) {
-          name = file.getStrData();
-        } else { // something special for 2-d array
-          const int64_t total_length = std::accumulate(
-              info.dims.begin(), info.dims.end(), static_cast<int64_t>(1),
-              std::multiplies<int64_t>());
-          boost::scoped_array<char> val_array(new char[total_length]);
-          file.getData(val_array.get());
-          file.closeData();
-          name = std::string(val_array.get(), total_length);
+    try {
+      if (exists(file, "name")) {
+        file.openData("name");
+        const auto info = file.getInfo();
+        std::string name;
+        if (info.type == ::NeXus::CHAR) {
+          if (info.dims.size() == 1) {
+            name = file.getStrData();
+          } else { // something special for 2-d array
+            const int64_t total_length = std::accumulate(
+                info.dims.begin(), info.dims.end(), static_cast<int64_t>(1),
+                std::multiplies<int64_t>());
+            boost::scoped_array<char> val_array(new char[total_length]);
+            file.getData(val_array.get());
+            file.closeData();
+            name = std::string(val_array.get(), total_length);
+          }
         }
-      }
-      file.closeData();
+        file.closeData();
 
-      if (!name.empty()) {
-        WS->mutableSample().setName(name);
+        if (!name.empty()) {
+          WS->mutableSample().setName(name);
+        }
       }
+    } catch (::NeXus::Exception &) {
+      // let it drop on floor if an exception occurs while reading sample
     }
     file.closeGroup();
   } catch (::NeXus::Exception &) {
-    // let it drop on floor
+    // If an exception occurs while opening the group "sample"
   }
 
   // get the duration
-- 
GitLab