Author: yurize
Date: Sat Apr 28 15:20:12 2012
New Revision: 1331785
URL: http://svn.apache.org/viewvc?rev=1331785&view=rev
Log:
Avoids crash due to IAE in link annotation converter.
By Christian Ohler.
https://reviews.apache.org/r/4769/
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/edit/KeepFocusInView.java
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/FullStructure.java
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/ParticipantAvatarDomImpl.java
incubator/wave/trunk/src/org/waveprotocol/wave/migration/helpers/FixLinkAnnotationsFilter.java
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/InvalidWaveRefException.java
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/WaverefEncoder.java
incubator/wave/trunk/test/org/waveprotocol/wave/model/waveref/WaverefEncoderTest.java
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/edit/KeepFocusInView.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/edit/KeepFocusInView.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/edit/KeepFocusInView.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/impl/edit/KeepFocusInView.java
Sat Apr 28 15:20:12 2012
@@ -108,7 +108,7 @@ public final class KeepFocusInView imple
// mutate the DOM, so the subsequent measurement queries will force
// synchronous layout, which can be slow.
OffsetPosition p = NativeSelectionUtil.slowGetPosition();
- if (p != null) {
+ if (p != null && p.offsetParent != null) {
Extent viewportInContent = scroller.getViewport();
double focusInViewport = measurer.top(viewport, p.offsetParent) +
p.top;
double focusInContent = focusInViewport + viewportInContent.getStart();
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/FullStructure.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/FullStructure.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/FullStructure.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/FullStructure.java
Sat Apr 28 15:20:12 2012
@@ -80,7 +80,7 @@ import org.waveprotocol.wave.model.wave.
* Implements structural accessors and mutators for wave-panel views.
*
*/
-public final class FullStructure implements UpgradeableDomAsViewProvider {
+public class FullStructure implements UpgradeableDomAsViewProvider {
/** Mapping of kinds to types. */
private static final ReadableStringSet KNOWN_KINDS;
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/ParticipantAvatarDomImpl.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/ParticipantAvatarDomImpl.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/ParticipantAvatarDomImpl.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/client/wavepanel/view/dom/ParticipantAvatarDomImpl.java
Sat Apr 28 15:20:12 2012
@@ -32,7 +32,7 @@ public final class ParticipantAvatarDomI
this.self = self.cast();
}
- static ParticipantAvatarDomImpl of(Element e) {
+ public static ParticipantAvatarDomImpl of(Element e) {
return new ParticipantAvatarDomImpl(e);
}
@@ -51,7 +51,7 @@ public final class ParticipantAvatarDomI
// Structure.
//
- void remove() {
+ public void remove() {
self.removeFromParent();
}
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/migration/helpers/FixLinkAnnotationsFilter.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/migration/helpers/FixLinkAnnotationsFilter.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/migration/helpers/FixLinkAnnotationsFilter.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/migration/helpers/FixLinkAnnotationsFilter.java
Sat Apr 28 15:20:12 2012
@@ -136,7 +136,7 @@ public class FixLinkAnnotationsFilter ex
}
public static String normalize(String oldHref) {
- if (oldHref.startsWith(OLD_PREFIX)) {
+ if (oldHref != null && oldHref.startsWith(OLD_PREFIX)) {
try {
return linkValueFromWaveValue(oldHref.substring(OLD_PREFIX.length()));
} catch (InvalidWaveRefException e) {
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/InvalidWaveRefException.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/InvalidWaveRefException.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/InvalidWaveRefException.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/InvalidWaveRefException.java
Sat Apr 28 15:20:12 2012
@@ -31,6 +31,11 @@ public class InvalidWaveRefException ext
this.ref = ref;
}
+ public InvalidWaveRefException(String ref, String message, Throwable cause) {
+ super(message, cause);
+ this.ref = ref;
+ }
+
public String getId() {
return ref;
}
Modified:
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/WaverefEncoder.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/WaverefEncoder.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/WaverefEncoder.java
(original)
+++
incubator/wave/trunk/src/org/waveprotocol/wave/model/waveref/WaverefEncoder.java
Sat Apr 28 15:20:12 2012
@@ -229,11 +229,10 @@ public class WaverefEncoder {
}
String waveletIdStr = decode(tokens[3]);
WaveletId waveletId = null;
-
try {
waveletId = WaveletId.of(waveletDomain, waveletIdStr);
} catch (IllegalArgumentException e) {
- throw new InvalidWaveRefException(path, "Invalid WaveletID:" +
e.getMessage());
+ throw new InvalidWaveRefException(path, "Invalid WaveletID", e);
}
if (tokens.length == 4) {
@@ -251,7 +250,11 @@ public class WaverefEncoder {
* @param string a percent-encoded US-ASCII string
* @return the decoded string
*/
- public String decode(String string) {
- return encoderDecoder.decode(string);
+ String decode(String string) throws InvalidWaveRefException {
+ try {
+ return encoderDecoder.decode(string);
+ } catch (IllegalArgumentException e) {
+ throw new InvalidWaveRefException(string, "Failed to decode", e);
+ }
}
}
Modified:
incubator/wave/trunk/test/org/waveprotocol/wave/model/waveref/WaverefEncoderTest.java
URL:
http://svn.apache.org/viewvc/incubator/wave/trunk/test/org/waveprotocol/wave/model/waveref/WaverefEncoderTest.java?rev=1331785&r1=1331784&r2=1331785&view=diff
==============================================================================
---
incubator/wave/trunk/test/org/waveprotocol/wave/model/waveref/WaverefEncoderTest.java
(original)
+++
incubator/wave/trunk/test/org/waveprotocol/wave/model/waveref/WaverefEncoderTest.java
Sat Apr 28 15:20:12 2012
@@ -153,7 +153,7 @@ public class WaverefEncoderTest extends
dummyEncoder.encodeToUriQueryString(fullySpecified));
}
- public void testDecodeCalledWithStringInput() {
+ public void testDecodeCalledWithStringInput() throws InvalidWaveRefException
{
assertEquals(decodeDummyString, dummyEncoder.decode("testString"));
}