StringIndexOutOfBoundsException

Joao
2005-09-20
2013-05-02
  • Joao

    Joao - 2005-09-20

    Hi,

    I tested the TV Sample with Intel Device Validator for UPnP Technologies version 1.0.1768.24077 and the result was the following:

    java.lang.StringIndexOutOfBoundsException: String index out of range: -5

        at java.lang.String.substring(String.java:1444)

        at org.cybergarage.upnp.event.Subscription.getSID(Subscription.java:71)

        at org.cybergarage.upnp.event.SubscriptionRequest.getSID(SubscriptionRequest.java:177)

        at org.cybergarage.upnp.event.SubscriptionRequest.hasSID(SubscriptionRequest.java:185)

        at org.cybergarage.upnp.Device.deviceEventSubscriptionRecieved(Device.java:1506)

        at org.cybergarage.upnp.Device.httpRequestRecieved(Device.java:1343)

        at org.cybergarage.http.HTTPServer.performRequestListener(HTTPServer.java:155)

        at org.cybergarage.http.HTTPServerThread.run(HTTPServerThread.java:47)

    I think this exception was thrown when the validator tried to do the command StateVariable: Power.

    Joo Paulo Lima

     
    • Joao

      Joao - 2005-09-20

      Hi,

      Actually, the exception is raised when the validator tries to unsubscribe from the power event, in the subscription tests.

      Joo Paulo Lima

       
    • Satoshi Konno

      Satoshi Konno - 2005-09-21

      Hi Joo,

      According to your output, the subscription request has a short subscription id. The subscription id might be started from "uuid" string. Fix Subscription::getSID() as the following to avoid the error.

          public final static String getSID(String headerValue)
          {
              if (headerValue == null)
                  return "";
              if (headerValue.startsWith(Subscription.UUID) == false)
                  return headerValue;
              return headerValue.substring(Subscription.UUID.length(), headerValue.length());
          }

      I will check your problem in more detail.

       

Log in to post a comment.