From d70d6a2cac7271b2f49805611d77cd3f7eb431f1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Patrik=20Lindstr=C3=B6m?= Date: Wed, 6 Nov 2013 16:15:52 +0200 Subject: [PATCH] Make component predicate matches exact (#12913) Change-Id: Ia9a938977437a2188a6f5b207789058abce62965 --- .../componentlocator/LegacyLocatorStrategy.java | 11 ++++++++++- .../componentlocator/VaadinFinderLocatorStrategy.java | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java index 5f5e0279ce..5123a57e5d 100644 --- a/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/LegacyLocatorStrategy.java @@ -499,7 +499,16 @@ public class LegacyLocatorStrategy implements LocatorStrategy { String widgetClassName = split[0]; String indexString = split[1].substring(0, split[1].length() - 1); - int widgetPosition = Integer.parseInt(indexString); + + int widgetPosition; + try { + widgetPosition = Integer.parseInt(indexString); + } catch (NumberFormatException e) { + // We've probably been fed a new-style Vaadin locator with a + // string-form predicate, that doesn't match anything in the + // search space. + return null; + } // AbsolutePanel in GridLayout has been removed -> skip it if (w instanceof VGridLayout diff --git a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java index 3390de86a4..96374e898a 100644 --- a/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java +++ b/client/src/com/vaadin/client/componentlocator/VaadinFinderLocatorStrategy.java @@ -241,6 +241,8 @@ public class VaadinFinderLocatorStrategy implements LocatorStrategy { } } + return null; + } else { int index = Integer.valueOf(predicateString); return index < potentialMatches.size() ? potentialMatches -- 2.39.5