COMMON: Fix potential bugs as prevent 14/11914/1
authorBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 8 Nov 2013 01:28:33 +0000 (10:28 +0900)
committerBon-Yong Lee <bonyong.lee@samsung.com>
Fri, 8 Nov 2013 01:28:33 +0000 (10:28 +0900)
Fix the followings:
Resource leak, inner class declaration warning and Unboxing without null-check

Change-Id: I08ed4d5a2d8c72d0d3d49fa253ae5f8492c60e36
Signed-off-by: Bon-Yong Lee <bonyong.lee@samsung.com>
org.tizen.common.connection/src/org/tizen/common/connection/explorer/ConnectionExplorerPanel.java
org.tizen.common.sdblib/src/org/tizen/sdblib/command/matcher/InverseMatcher.java
org.tizen.common.sdblib/src/org/tizen/sdblib/service/FileEntryOutputStream.java [changed mode: 0644->0755]
org.tizen.common/src/org/tizen/common/util/PropertyUtil.java
org.tizen.common/test/src/org/tizen/common/util/ImageUtilTest.java

index f6109e4..893f9dd 100755 (executable)
@@ -1386,7 +1386,7 @@ public class ConnectionExplorerPanel implements IDeviceChangeListener, IDebugBri
         return tableViewer;
     }
 
-    class FileNameValidator implements IInputValidator
+    static class FileNameValidator implements IInputValidator
     {
         @Override
         public String isValid(String fileName)
index 4a6c8df..dbec17c 100755 (executable)
@@ -69,7 +69,13 @@ implements Matcher<Boolean>
        @Override\r
     public Boolean getResult()\r
     {\r
-           return !this.matcher.getResult();\r
+           Boolean b = this.matcher.getResult();\r
+           if ( null == b )\r
+           {\r
+               return true;\r
+           }\r
+           \r
+           return !b;\r
     }\r
 \r
        /* (non-Javadoc)\r
old mode 100644 (file)
new mode 100755 (executable)
index bbe5553..c6edc04
@@ -116,7 +116,6 @@ extends OutputStream
                this.timeOut = timeOut;\r
                this.channel = SmartDevelopmentBridge.getBridge().openChannel();\r
        this.channel.configureBlocking( true );\r
-               \r
         // target a specific device\r
         initializeDevice( channel, this.entry.getDevice().getSerialNumber() );\r
 \r
@@ -132,7 +131,6 @@ extends OutputStream
             channel.close();\r
             throw new SyncException( RESULT_CONNECTION_ERROR );\r
         }\r
-        \r
         final byte[] remotePath = string2bytes( this.entry.getFullPath() );\r
         try\r
         {\r
@@ -164,8 +162,8 @@ extends OutputStream
         // create the buffer used to read.\r
         // we read max SYNC_DATA_MAX, but we need 2 4 bytes at the beginning.\r
         System.arraycopy( ID_DATA, 0, buffer, 0, ID_DATA.length );\r
-\r
        }\r
+       \r
        /* (non-Javadoc)\r
         * @see java.io.OutputStream#write(int)\r
         */\r
@@ -318,6 +316,7 @@ extends OutputStream
         }\r
 \r
                SdbHelper.write( channel, createReq(ID_QUIT, 0) );\r
+               channel.close();\r
            super.close();\r
        }\r
 }\r
index bf98f5a..60a0171 100755 (executable)
@@ -75,10 +75,6 @@ public abstract class PropertyUtil {
                catch ( final IOException e ) {
                    logger.info( "Ignore exception" );
                }
-               finally
-               {
-                       tryClose( inputStream );
-               }
                return props;
        }
 
index 0a11650..ba810d2 100755 (executable)
@@ -290,17 +290,30 @@ public class ImageUtilTest
     public void test_getBufferedImage() throws Exception {
         final URL virtualJPGPathUrl = new URL(JPG_TEST_URL);
         InputStream input = virtualJPGPathUrl.openStream();
-        BufferedImage image = ImageUtil.getBufferedImage(input);
-        Assert.assertNotNull(image);
-        image.flush();
-        IOUtil.tryClose(input);
+        try
+        {
+            BufferedImage image = ImageUtil.getBufferedImage(input);
+            Assert.assertNotNull(image);
+            image.flush();
+        }
+        finally
+        {
+            IOUtil.tryClose(input);
+        }
 
         final URL virtualPNGPathUrl = new URL(TEST_URL);
         input = virtualPNGPathUrl.openStream();
-        image = ImageUtil.getBufferedImage(input);
-        Assert.assertNotNull(image);
-        image.flush();
-        IOUtil.tryClose(input);
+        try
+        {
+            BufferedImage image = ImageUtil.getBufferedImage(input);
+            Assert.assertNotNull(image);
+            image.flush();
+        }
+        finally
+        {
+            
+            IOUtil.tryClose(input);
+        }
     }
 
 }