[Title] Fix as prevent 97/11497/1
authorBon-Yong Lee <bonyong.lee@samsung.com>
Tue, 29 Oct 2013 02:19:17 +0000 (11:19 +0900)
committerBon-Yong Lee <bonyong.lee@samsung.com>
Tue, 29 Oct 2013 02:19:17 +0000 (11:19 +0900)
[Desc.]
[Issue]

Change-Id: I73cd37fed8fcb9c01c364b50834e89a88ad1d17c
Signed-off-by: Bon-Yong Lee <bonyong.lee@samsung.com>
12 files changed:
org.tizen.common.builder/src/org/tizen/common/builder/BuildProcess.java
org.tizen.common.externals/src/org/mihalis/opal/itemSelector/DualList.java [changed mode: 0644->0755]
org.tizen.common.sdblib/src/org/tizen/sdblib/DeviceMonitor.java
org.tizen.common.sdblib/src/org/tizen/sdblib/SmartDevelopmentBridge.java
org.tizen.common.sdblib/src/org/tizen/sdblib/command/Command.java [changed mode: 0644->0755]
org.tizen.common.sdblib/src/org/tizen/sdblib/command/matcher/InverseMatcher.java [changed mode: 0644->0755]
org.tizen.common.sdblib/src/org/tizen/sdblib/service/SyncService.java [changed mode: 0644->0755]
org.tizen.common.sign/src/org/tizen/common/sign/preferences/SigningPreferencePage.java
org.tizen.common/src/org/tizen/common/core/application/InstallPathConfig.java
org.tizen.common/src/org/tizen/common/core/command/zip/ZipCommand.java
org.tizen.common/src/org/tizen/common/daemon/AbstractServer.java
org.tizen.common/src/org/tizen/common/util/DefferedTaskManager.java

index 4611f92..8e24663 100755 (executable)
@@ -28,6 +28,8 @@
  */\r
 package org.tizen.common.builder;\r
 \r
+import static java.util.Collections.emptyList;\r
+\r
 import java.io.File;\r
 import java.io.IOException;\r
 import java.util.ArrayList;\r
@@ -466,10 +468,14 @@ public class BuildProcess
      * @throws IOException\r
      */\r
     public Collection<Resource> getResult(Resource ... resources) throws IOException {\r
-        Collection<Resource> result = new HashSet<Resource>();\r
-        \r
+        final ResourceLayer resourceLayer = getLastResourceLayer();\r
+        if ( null == resourceLayer )\r
+        {\r
+            return emptyList();\r
+        }\r
+        final Collection<Resource> result = new HashSet<Resource>();\r
         for (Resource resource : resources) {\r
-            Resource resultResource = getLastBuilder().getResourceLayer().getResource( resource.getPath() );\r
+            final Resource resultResource = resourceLayer.getResource( resource.getPath() );\r
             result.add( resultResource );\r
        }\r
         \r
@@ -482,9 +488,8 @@ public class BuildProcess
      * @return\r
      */\r
     protected boolean isValidResource(Resource resource) {\r
-        ResourceLayer iter = getLastBuilder().getResourceLayer();\r
-        \r
-        ResourceLayer resourceLayer = resource.getLayer();\r
+        final ResourceLayer resourceLayer = resource.getLayer();\r
+        ResourceLayer iter = getLastResourceLayer();\r
         while ( iter != null ) {\r
             if ( iter == resourceLayer ) {\r
                 return !iter.isFilterResource( resource );\r
old mode 100644 (file)
new mode 100755 (executable)
index 8b6b902..d03bd16
@@ -10,6 +10,8 @@
  *******************************************************************************/\r
 package org.mihalis.opal.itemSelector;\r
 \r
+import java.io.IOException;\r
+import java.io.InputStream;\r
 import java.util.ArrayList;\r
 import java.util.List;\r
 \r
@@ -212,17 +214,30 @@ public class DualList extends Composite {
         */\r
        private Button createButton(final String fileName, final boolean verticalExpand, final int alignment) {\r
                final Button button = new Button(this, SWT.PUSH);\r
-               final Image image = new Image(this.getDisplay(), this.getClass().getClassLoader().getResourceAsStream("images/" + fileName));\r
-               button.setImage(image);\r
-               button.setLayoutData(new GridData(GridData.CENTER, alignment, false, verticalExpand));\r
-               button.addDisposeListener(new DisposeListener() {\r
-\r
-                       @Override\r
-                       public void widgetDisposed(final DisposeEvent e) {\r
-                               SWTGraphicUtil.dispose(image);\r
-                       }\r
-               });\r
-               return button;\r
+               \r
+               // Fix resource leak by bonyong.lee\r
+               final InputStream in = this.getClass().getClassLoader().getResourceAsStream("images/" + fileName);\r
+               try\r
+               {\r
+                   final Image image = new Image(this.getDisplay(), in);\r
+                   button.setImage(image);\r
+                   button.setLayoutData(new GridData(GridData.CENTER, alignment, false, verticalExpand));\r
+                   button.addDisposeListener(new DisposeListener() {\r
+                       \r
+                       @Override\r
+                       public void widgetDisposed(final DisposeEvent e) {\r
+                           SWTGraphicUtil.dispose(image);\r
+                       }\r
+                   });\r
+                   return button;\r
+               }\r
+               finally\r
+               {\r
+                   if ( null != in )\r
+                   {\r
+                       try { in.close(); } catch ( final IOException e ) { }\r
+                   }\r
+               }\r
        }\r
 \r
        /**\r
index 485e7ee..a9c1ded 100755 (executable)
@@ -181,6 +181,10 @@ extends AbstractServer
      * @throws IOException
      */
     private boolean sendDeviceListMonitoringRequest() throws TimeoutException, IOException {
+        if ( null == mMainSdbConnection )
+        {
+            return false;
+        }
         byte[] request = SdbHelper.formSdbRequest("host:track-devices"); //$NON-NLS-1$
         Log.d("DeviceMonitor", "send monitoring request");
         try {
@@ -375,7 +379,8 @@ extends AbstractServer
                                }
                        }
 
-                       if (mMainSdbConnection != null && mMonitoring == false) {
+                       if ( !mMonitoring )
+                       {
                                mMonitoring = sendDeviceListMonitoringRequest();
                        }
 
index eb64161..9901f65 100755 (executable)
@@ -693,7 +693,7 @@ SmartDevelopmentBridge
             synchronized ( this )
             {
                 try {
-                    wait();
+                    this.wait();
                 } catch (InterruptedException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
@@ -722,7 +722,7 @@ SmartDevelopmentBridge
             mStarted = isStarted;
             synchronized(this)
             {
-               notifyAll();
+               this.notifyAll();
             }
         }finally
         {
old mode 100644 (file)
new mode 100755 (executable)
index 980e9f6..ec8bbf5
@@ -104,8 +104,8 @@ implements ICommand, ICommandWithArgument, ICommandWithArgument2
                notNull( receiver );\r
                \r
         final SocketChannel channel = sdb.openChannel();\r
-        channel.configureBlocking( getMaxTimeToRespond() <= 0 );\r
         try {\r
+            channel.configureBlocking( getMaxTimeToRespond() <= 0 );\r
                \r
                sendRequest( device, channel );\r
                \r
old mode 100644 (file)
new mode 100755 (executable)
index 45f774f..4a6c8df
@@ -25,6 +25,8 @@
  */\r
 package org.tizen.sdblib.command.matcher;\r
 \r
+import static org.tizen.sdblib.util.Assert.notNull;\r
+\r
 import java.io.IOException;\r
 \r
 import org.tizen.sdblib.command.Matcher;\r
@@ -57,6 +59,7 @@ implements Matcher<Boolean>
                Matcher<Boolean> matcher\r
        )\r
        {\r
+           notNull( matcher );\r
                this.matcher = matcher;\r
        }\r
 \r
old mode 100644 (file)
new mode 100755 (executable)
index 30e9cd3..40f6d89
@@ -672,7 +672,10 @@ implements Closeable
                tryClose( in );
                try
             {
-                   out.close();
+                   if ( null != out )
+                   {
+                       out.close();
+                   }
             }
                catch ( final SyncException e)
                {
index 633baf3..fb6356c 100755 (executable)
@@ -1084,7 +1084,7 @@ public class SigningPreferencePage extends PreferencePage implements IWorkbenchP
     /**
      * TextCellEditor for password processing
      */
-    public class PasswordTextCellEditor extends TextCellEditor {
+    public static class PasswordTextCellEditor extends TextCellEditor {
         public PasswordTextCellEditor(Composite composite) {
             super(composite);
         }
index accd523..e4d59d2 100755 (executable)
@@ -253,10 +253,6 @@ final public class InstallPathConfig {
             }
         }
         
-        if ( latestProfileInfo == null ) {
-            return null;
-        }
-        
         return latestProfileInfo;
     }
     
index 6a40598..5d670a3 100755 (executable)
@@ -278,18 +278,18 @@ extends FileHandlingCommand<Object>
                 final String relative = getRelativePath( baseDir, filePath );
                 logger.trace( "Relative path :{}", relative );
 
-                final ZipEntry entry = createEntry( relative );
-                zipOut.putNextEntry( entry );
-                InputStream fileIn = handler.read( filePath );
+                final InputStream fileIn = handler.read( filePath );
                 try
                 {
+                    final ZipEntry entry = createEntry( relative );
+                    zipOut.putNextEntry( entry );
                     IOUtil.redirect( fileIn, zipOut );
                 }
                 finally
                 {
                     tryClose( fileIn );
+                    zipOut.closeEntry();
                 }
-                zipOut.closeEntry();
                 logger.debug( "Zip {}", relative );
             }
         }
index 616d46d..aae5780 100755 (executable)
@@ -149,7 +149,7 @@ implements Server, Runnable
             lock.unlock();\r
             synchronized ( this )\r
             {\r
-                notifyAll();\r
+                this.notifyAll();\r
             }\r
         }\r
     }\r
@@ -201,7 +201,7 @@ implements Server, Runnable
             {\r
                 synchronized ( this )\r
                 {\r
-                    wait();\r
+                    this.wait();\r
                 }\r
             } catch ( final InterruptedException e )\r
             {\r
index 594af64..a5346ec 100755 (executable)
@@ -119,7 +119,7 @@ DefferedTaskManager
      * \r
      * @return idle time\r
      */\r
-    public\r
+    synchronized public\r
     long\r
     getIdleTime()\r
     {\r