*/\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
* @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
* @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
*******************************************************************************/\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
*/\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
* @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 {
}
}
- if (mMainSdbConnection != null && mMonitoring == false) {
+ if ( !mMonitoring )
+ {
mMonitoring = sendDeviceListMonitoringRequest();
}
synchronized ( this )
{
try {
- wait();
+ this.wait();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
mStarted = isStarted;
synchronized(this)
{
- notifyAll();
+ this.notifyAll();
}
}finally
{
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
*/\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
Matcher<Boolean> matcher\r
)\r
{\r
+ notNull( matcher );\r
this.matcher = matcher;\r
}\r
\r
tryClose( in );
try
{
- out.close();
+ if ( null != out )
+ {
+ out.close();
+ }
}
catch ( final SyncException e)
{
/**
* TextCellEditor for password processing
*/
- public class PasswordTextCellEditor extends TextCellEditor {
+ public static class PasswordTextCellEditor extends TextCellEditor {
public PasswordTextCellEditor(Composite composite) {
super(composite);
}
}
}
- if ( latestProfileInfo == null ) {
- return null;
- }
-
return latestProfileInfo;
}
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 );
}
}
lock.unlock();\r
synchronized ( this )\r
{\r
- notifyAll();\r
+ this.notifyAll();\r
}\r
}\r
}\r
{\r
synchronized ( this )\r
{\r
- wait();\r
+ this.wait();\r
}\r
} catch ( final InterruptedException e )\r
{\r
* \r
* @return idle time\r
*/\r
- public\r
+ synchronized public\r
long\r
getIdleTime()\r
{\r