[Esbox-commits] r1995 - in branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1: command core

eswartz at garage.maemo.org eswartz at garage.maemo.org
Mon Aug 24 16:33:40 EEST 2009


Author: eswartz
Date: 2009-08-24 16:33:39 +0300 (Mon, 24 Aug 2009)
New Revision: 1995

Modified:
   branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java
   branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
Log:
Fix bug 4386

Modified: branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java	2009-08-24 09:33:23 UTC (rev 1994)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/command/GetCurrentTargetCommand.java	2009-08-24 13:33:39 UTC (rev 1995)
@@ -55,8 +55,9 @@
 
 		Process process = createProcess(currentTargetCommand, null);
 
-		String currentTarget = getInputFromProcessAndWait(process, false, 0);
-		
+		// allow errors due to ESbox #4386
+		String currentTarget = getInputFromProcessAndWait(process, true, 0);
+
 		return currentTarget;
 	}
 

Modified: branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java
===================================================================
--- branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	2009-08-24 09:33:23 UTC (rev 1994)
+++ branches/work_Ed/org.maemo.esbox.scratchbox.sb1/src/org/maemo/esbox/internal/scratchbox/sb1/core/Scratchbox1SDK.java	2009-08-24 13:33:39 UTC (rev 1995)
@@ -83,9 +83,9 @@
 	 */
 	@SuppressWarnings("unchecked")
 	public List<String> getTargets() throws MicaException {
-		String[] targetsArray = (String[]) getCache().get(TARGETS_KEY, String[].class);
-		if (targetsArray != null)
-			return Arrays.asList(targetsArray);
+		List<String> cachedTargetsList = getCachedTargets();
+		if (cachedTargetsList != null)
+			return cachedTargetsList;
 		
 		// no, this call itself is invoked as part of initialization
 		//ensureInitialized();
@@ -104,6 +104,17 @@
 		return targets;
 	}
 
+	/**
+	 * @return
+	 */
+	private List<String> getCachedTargets() {
+		String[] targetsArray = (String[]) getCache().get(TARGETS_KEY, String[].class);
+		if (targetsArray != null)
+			return Arrays.asList(targetsArray);
+		else
+			return null;
+	}
+
 	/* (non-Javadoc)
 	 * @see org.maemo.esbox.internal.api.scratchbox.core.sdk.AbstractScratchboxSDK#init()
 	 */
@@ -335,6 +346,18 @@
 		
 		currentTarget = (String) wrapCommand(getCurrentTargetCommand, EMPTY_ARGS);
 		
+		// be more defensive in case there is garbage here 
+		List<String> cachedTargets = getCachedTargets();
+		if (cachedTargets != null) {
+			String[] words = currentTarget.split("\\s+");
+			for (String word : words) {
+				if (cachedTargets.contains(word)) { 
+					currentTarget = word;
+					break;
+				}
+			}
+		}
+		
 		getCache().set(CURRENT_TARGET_KEY, currentTarget);
 		return currentTarget;
 	}



More information about the Esbox-commits mailing list