Java 应用程序引擎上的任务servlet中的ArrayIndexOutOfBound

Java 应用程序引擎上的任务servlet中的ArrayIndexOutOfBound,java,google-app-engine,Java,Google App Engine,我在app engine上的任务servlet中遇到问题。 有时我会收到arraylist indexoutofbound异常。 我已将3个字符串(子域)正确添加到arraylist的日志打印,但当我尝试访问时: stringUser.add(entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o)); 我收到: Uncaught exception from servlet java.lang.IndexOutOfBound

我在app engine上的任务servlet中遇到问题。 有时我会收到arraylist indexoutofbound异常。 我已将3个字符串(子域)正确添加到arraylist的日志打印,但当我尝试访问时:

stringUser.add(entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o));
我收到:

Uncaught exception from servlet java.lang.IndexOutOfBoundsException: Index: 9, Size: 4

怎么可能呢?这是我的密码

String [] sottodomini=subdomains.split(",");

           listaDeiSottodomini.add(consumerKey);
           if(sottodomini.length>0 ){
           for(int y=0;y<sottodomini.length;y++){
               if(!sottodomini[y].equals("")){
                   log.info("Aggiungo "+sottodomini[y]+" alla lista dei sottodomini abilitati al contact sharing");
               listaDeiSottodomini.add(sottodomini[y]);  
               }
           }
           }
        log.info("ArrayList value "+listaDeiSottodomini);
        try {
            UserService myService = new UserService("My Application");
            myService.setOAuthCredentials(oauthParameters, signer);

            for(int o=0;o<listaDeiSottodomini.size();o++){
            URL metafeedUrl = new URL("https://apps-apis.google.com/a/feeds/"+listaDeiSottodomini.get(o)+"/user/2.0");
            while (metafeedUrl != null) {
                UserFeed resultFeed;

                resultFeed = myService.getFeed(metafeedUrl, UserFeed.class);

                entries.addAll(resultFeed.getEntries());


                for(int i=0; i<resultFeed.getEntries().size(); i++) {
                    UserEntry entry = resultFeed.getEntries().get(i);


                    if(!entry.getLogin().getSuspended()){
                    stringUser.add(entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o));
                    }else{
                        log.warning("L'utente "+entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o)+" è in stato sospeso e quindi non è stato considerato nella procedura di condivisione"); 

                    }
                    }
                // Check for next page
                Link nextLink = resultFeed.getNextLink();
                if (nextLink == null) {
                    metafeedUrl = null;
                } else {
                    metafeedUrl = new URL(nextLink.getHref());
                }
            }
            }

        } catch (AppsForYourDomainException e) {
            log.warning("Errore di AppsForYourDomainException nel recupero degli utenti con messaggio "+e.getMessage().toString());
        } catch (ServiceException e) {
            log.warning("Errore di ServiceException nel recupero degli utenti con messaggio "+e.getMessage().toString());
        } catch (OAuthException e) {
            log.warning("Errore di OAuthException nel recupero degli utenti con messaggio "+e.getMessage().toString());

        }


}
String[]sottodomini=subdomains.split(“,”);
添加(消费市场);
如果(sottodomini.长度>0){

对于(int y=0;yy您应该发布整个stacktrace,并指出哪一行是itOr中指示的行。不要发布它。相信堆栈跟踪。它会告诉您引发异常的行号和文件。将错误的假设放在一边,即您的代码是正确的,在调试器中导航到该行,并找出h该数组的实际状态与您的假设相冲突。
Uncaught exception from servlet java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
String [] sottodomini=subdomains.split(",");

           listaDeiSottodomini.add(consumerKey);
           if(sottodomini.length>0 ){
           for(int y=0;y<sottodomini.length;y++){
               if(!sottodomini[y].equals("")){
                   log.info("Aggiungo "+sottodomini[y]+" alla lista dei sottodomini abilitati al contact sharing");
               listaDeiSottodomini.add(sottodomini[y]);  
               }
           }
           }
        log.info("ArrayList value "+listaDeiSottodomini);
        try {
            UserService myService = new UserService("My Application");
            myService.setOAuthCredentials(oauthParameters, signer);

            for(int o=0;o<listaDeiSottodomini.size();o++){
            URL metafeedUrl = new URL("https://apps-apis.google.com/a/feeds/"+listaDeiSottodomini.get(o)+"/user/2.0");
            while (metafeedUrl != null) {
                UserFeed resultFeed;

                resultFeed = myService.getFeed(metafeedUrl, UserFeed.class);

                entries.addAll(resultFeed.getEntries());


                for(int i=0; i<resultFeed.getEntries().size(); i++) {
                    UserEntry entry = resultFeed.getEntries().get(i);


                    if(!entry.getLogin().getSuspended()){
                    stringUser.add(entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o));
                    }else{
                        log.warning("L'utente "+entry.getTitle().getPlainText()+"@"+listaDeiSottodomini.get(o)+" è in stato sospeso e quindi non è stato considerato nella procedura di condivisione"); 

                    }
                    }
                // Check for next page
                Link nextLink = resultFeed.getNextLink();
                if (nextLink == null) {
                    metafeedUrl = null;
                } else {
                    metafeedUrl = new URL(nextLink.getHref());
                }
            }
            }

        } catch (AppsForYourDomainException e) {
            log.warning("Errore di AppsForYourDomainException nel recupero degli utenti con messaggio "+e.getMessage().toString());
        } catch (ServiceException e) {
            log.warning("Errore di ServiceException nel recupero degli utenti con messaggio "+e.getMessage().toString());
        } catch (OAuthException e) {
            log.warning("Errore di OAuthException nel recupero degli utenti con messaggio "+e.getMessage().toString());

        }


}