Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIndexOutOfBoundsException #63

Open
jilen opened this issue Aug 28, 2013 · 2 comments
Open

StringIndexOutOfBoundsException #63

jilen opened this issue Aug 28, 2013 · 2 comments

Comments

@jilen
Copy link

jilen commented Aug 28, 2013

java.lang.StringIndexOutOfBoundsException: String index out of range: 98
    java.lang.AbstractStringBuilder.deleteCharAt(AbstractStringBuilder.java:762)
    java.lang.StringBuilder.deleteCharAt(StringBuilder.java:258)
    com.google.sitebricks.StringBuilderRespond.chew(StringBuilderRespond.java:81)
    com.google.sitebricks.rendering.control.EmbeddedRespond.chew(EmbeddedRespond.java:100)
    com.google.sitebricks.rendering.control.XmlWidget.writeOpenTag(XmlWidget.java:115)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:72)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:79)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.EmbedWidget.render(EmbedWidget.java:66)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:79)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.DecorateWidget.render(DecorateWidget.java:57)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:79)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:79)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.rendering.control.XmlWidget.render(XmlWidget.java:79)
    com.google.sitebricks.rendering.control.ProceedingWidgetChain.render(ProceedingWidgetChain.java:21)
    com.google.sitebricks.routing.WidgetRoutingDispatcher.bindAndRespond(WidgetRoutingDispatcher.java:121)
    com.google.sitebricks.routing.WidgetRoutingDispatcher.dispatch(WidgetRoutingDispatcher.java:75)
    com.google.sitebricks.SitebricksFilter.doFilter(SitebricksFilter.java:59)
    com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    com.google.sitebricks.HiddenMethodFilter.doFilter(HiddenMethodFilter.java:70)
    com.google.inject.servlet.FilterDefinition.doFilter(FilterDefinition.java:163)
    com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:58)
    com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:118)
    com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:113)
@jilen
Copy link
Author

jilen commented Aug 28, 2013

This issue appears rarely.

@kidogo
Copy link

kidogo commented Dec 20, 2015

This issue is cause by EmbeddedRespondFactory using single instance of com.google.sitebricks.StringBuilderRespond, and therefore a single instance of StringBuilder in different requests/threads.

This causes the StringIndexOutOfBoundsException, and some other times cause output for one page to be currupted with output from other page instances.

A work arround is to replace EmbeddedRespondFactory with

@Immutable class EmbeddedRespondFactory {
  //private final Respond respond = new StringBuilderRespond(new Object());

  public EmbeddedRespond get(Map<String, ArgumentWidget> arguments) {
      final Respond respond = new StringBuilderRespond(new Object());
    return new EmbeddedRespond(arguments, respond);
  }
}

kidogo added a commit to kidogo/sitebricks that referenced this issue Jan 1, 2018
Fix dhanji#63 : avoid StringBuilderRespond singleton + pass context to StringBuilderRespond
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants