Svace : Apply svace fixes
authorbdragon.park <bdragon.park@samsung.com>
Tue, 17 Oct 2017 05:15:20 +0000 (14:15 +0900)
committerbdragon.park <bdragon.park@samsung.com>
Tue, 17 Oct 2017 06:11:30 +0000 (15:11 +0900)
Signed-off-by: bdragon.park <bdragon.park@samsung.com>
rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java
rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java

index 7e100e0..1416211 100755 (executable)
@@ -80,7 +80,11 @@ public class MetaModelUtil {
      */
     public static Build copyDefaultBuildModelAndLoad(String destination) throws IOException, JAXBException {
         InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_BUILD_META_XML);
-        return copyDefaultModelAndLoad(Build.class, source, destination);
+        Build model = copyDefaultModelAndLoad(Build.class, source, destination);
+        if (source != null) {
+            source.close();
+        }
+        return model;
     }
 
     /**
@@ -92,7 +96,11 @@ public class MetaModelUtil {
      */
     public static Flash copyDefaultFlashModelAndLoad(String destination) throws IOException, JAXBException {
         InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_FLASH_META_XML);
-        return copyDefaultModelAndLoad(Flash.class, source, destination);
+        Flash model = copyDefaultModelAndLoad(Flash.class, source, destination);
+        if (source != null) {
+            source.close();
+        }
+        return model;
     }
 
     /**
@@ -104,7 +112,11 @@ public class MetaModelUtil {
      */
     public static Debugs copyDefaultDebugModelAndLoad(String destination) throws IOException, JAXBException {
         InputStream source = RtMetaPlugin.class.getResourceAsStream("resources" + File.separator + IModelConstants.FILE_NAME_DEBUG_META_XML);
-        return copyDefaultModelAndLoad(Debugs.class, source, destination);
+        Debugs model = copyDefaultModelAndLoad(Debugs.class, source, destination);
+        if (source != null) {
+            source.close();
+        }
+        return model;
     }
 
     private static <T> T copyDefaultModelAndLoad(Class<T> clazz, InputStream source, String destination) throws JAXBException, IOException {
@@ -315,18 +327,27 @@ public class MetaModelUtil {
             throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
         InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/buildSpec.xsd"); //$NON-NLS-1$
         validate(xmlFileStream, xsdFileStream);
+        if (xsdFileStream != null) {
+            xsdFileStream.close();
+        }
     }
 
     public static void validateFlashFile(InputStream xmlFileStream)
             throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
         InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/flashSpec.xsd"); //$NON-NLS-1$
         validate(xmlFileStream, xsdFileStream);
+        if (xsdFileStream != null) {
+            xsdFileStream.close();
+        }
     }
 
     public static void validateDebugFile(InputStream xmlFileStream)
             throws FileNotFoundException, ParserConfigurationException, SAXException, IOException {
         InputStream xsdFileStream = RtMetaPlugin.class.getResourceAsStream("resources/debugSpec.xsd"); //$NON-NLS-1$
         validate(xmlFileStream, xsdFileStream);
+        if (xsdFileStream != null) {
+            xsdFileStream.close();
+        }
     }
 
 }
index 4864d59..eb04bd4 100644 (file)
@@ -123,7 +123,7 @@ public class ToggleSaveLogAction extends AbstractTerminalAction {
     private String openFileDialog() {
         TabFolderManager manager = (TabFolderManager) view.getAdapter(TabFolderManager.class);
         CTabItem item = manager.getActiveTabItem();
-        Assert.isTrue(!item.isDisposed());
+        Assert.isTrue(item != null && !item.isDisposed());
 
         String DefaultPath = null;
         // IProject project = ResourceUtil.getCurrentProject();
@@ -137,10 +137,13 @@ public class ToggleSaveLogAction extends AbstractTerminalAction {
         }
         String result = openFileDialog(DefaultPath, getLogFileName(item.getText()));
         // check if dialog cancel
-        if (result == null) {
-            getSaveLogHandler().setCancelDialog(true);
-        } else {
-            getSaveLogHandler().setCancelDialog(false);
+        ToggleSaveLogHandler handler = getSaveLogHandler();
+        if (handler != null) {
+            if (result == null) {
+                handler.setCancelDialog(true);
+            } else {
+                handler.setCancelDialog(false);
+            }
         }
         return result;
     }