cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From olivierlemasle <>
Subject [GitHub] cloudstack pull request: CLOUDSTACK-9358: StringIndexOutOfBoundsEx...
Date Wed, 20 Apr 2016 14:18:57 GMT
GitHub user olivierlemasle opened a pull request:

    CLOUDSTACK-9358: StringIndexOutOfBoundsException on events

    Fixes JSON deserialization of `cmdInfo` (current process fails with `StringIndexOutOfBoundsException`
when `cmdEventType` is the last parameter in the JSON string).
    A {{StringIndexOutOfBoundsException}} is thrown in some cases during event publication.
    Example: a stopVirtualMachine API request is executed, and fails with:
    2016-04-15 09:24:43,080 ERROR [o.a.c.f.m.MessageDispatcher] (catalina-exec-1:ctx-840cbaa7
ctx-8daf0e9c ctx-f63af073) Unexpected exception when calling
            at sun.reflect.GeneratedMethodAccessor307.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(
            at java.lang.reflect.Method.invoke(
            at org.apache.cloudstack.framework.messagebus.MessageDispatcher.dispatch(
            at org.apache.cloudstack.framework.messagebus.MessageDispatcher.onPublishMessage(
            at org.apache.cloudstack.framework.messagebus.MessageBusBase$SubscriptionNode.notifySubscribers(
            at org.apache.cloudstack.framework.messagebus.MessageBusBase.publish(
            at org.apache.cloudstack.managed.context.impl.DefaultManagedContext$
            at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(
            at org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(
            at javax.servlet.http.HttpServlet.service(
            at javax.servlet.http.HttpServlet.service(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.apache.tomcat.websocket.server.WsFilter.doFilter(
            at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
            at org.apache.catalina.core.ApplicationFilterChain.doFilter(
            at org.apache.catalina.core.StandardWrapperValve.invoke(
            at org.apache.catalina.core.StandardContextValve.invoke(
            at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
            at org.apache.catalina.core.StandardHostValve.invoke(
            at org.apache.catalina.valves.ErrorReportValve.invoke(
            at org.apache.catalina.valves.AccessLogValve.invoke(
            at org.apache.catalina.core.StandardEngineValve.invoke(
            at org.apache.catalina.connector.CoyoteAdapter.service(
            at org.apache.coyote.http11.AbstractHttp11Processor.process(
            at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
            at java.util.concurrent.ThreadPoolExecutor.runWorker(
            at java.util.concurrent.ThreadPoolExecutor$
            at org.apache.tomcat.util.threads.TaskThread$
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -468
            at java.lang.String.substring(
            at sun.reflect.GeneratedMethodAccessor307.invoke(Unknown Source)
            ... 41 more
    The VM is not stopped, and the API returns the following error:
          HTTP/1.1 530 : InvocationTargetException when invoking event handler for subject:
    The error comes from JSON parsing in
    The `substring()` method throws a StringIndexOutOfBoundsException when `cmdEventType`
is the last field in the JSON object.
    The JSON object being the JSON serialization of a `HashMap` object, the order of the fields
is not guaranteed. In my tests, I observed that there is no error with Java 7, but it fails
with Java 8, which has a different Hashmap implementation.
    For example, with request,
cmdInfo is:
    and it fails.
    Please note that the error is not present for all API requests, depending on the parameters

You can merge this pull request into a Git repository by running:

    $ git pull fix-CLOUDSTACK-9358

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1503
commit 49392584179d5b17c49296620ecb26e471c2d04f
Author: Olivier Lemasle <>
Date:   2016-04-20T13:25:17Z

    CLOUDSTACK-9358: StringIndexOutOfBoundsException on events
    Fixes JSON deserialization of cmdInfo (current process fails with
    StringIndexOutOfBoundsException when cmdEventType is the last parameter
    in the JSON string.


If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at or file a JIRA ticket
with INFRA.

View raw message