From 899a7ca7fed357bec31680e5630cb900e3fb0e19 Mon Sep 17 00:00:00 2001 From: "bdragon.park" Date: Tue, 17 Oct 2017 14:15:20 +0900 Subject: [PATCH] Svace : Apply svace fixes Signed-off-by: bdragon.park --- .../tizen/rt/product/meta/util/MetaModelUtil.java | 27 +++++++++++++++++++--- .../terminal/view/ui/tabs/ToggleSaveLogAction.java | 13 +++++++---- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java b/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java index 7e100e0..1416211 100755 --- a/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java +++ b/rt-ide/tizen.rt.product.meta/src/org/tizen/rt/product/meta/util/MetaModelUtil.java @@ -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 copyDefaultModelAndLoad(Class 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(); + } } } diff --git a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java index 4864d59..eb04bd4 100644 --- a/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java +++ b/rt-ide/tizen.rt.terminalex.plugin/src/org/tizen/rt/ide/terminal/view/ui/tabs/ToggleSaveLogAction.java @@ -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; } -- 2.7.4