2017-11-01 10 views
0

HTTP要求を行うためにGsonでRetrofitを使用しています。しかし、要求の後、私はこれを下に誤りがある。誰かがこれを解決するのに私を助けてくれる?GSON Stackoverflowerrorを改訂する

Caused by: java.lang.StackOverflowError: stack size 1037KB 
    at com.google.gson.internal.$Gson$Types.checkNotPrimitive($Gson$Types.java:434) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:544) 
    at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553) 
    at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546) 
    at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553) 
    at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:546) 
    at com.google.gson.internal.$Gson$Types.canonicalize($Gson$Types.java:111) 
    at com.google.gson.internal.$Gson$Types$WildcardTypeImpl.<init>($Gson$Types.java:553) 

MainActivity.java

if (retrofit == null) { 
      System.out.println("building:"); 
      Gson gson = new GsonBuilder() 
        .setExclusionStrategies(new ExclusionStrategy() { 
         @Override 
         public boolean shouldSkipField(FieldAttributes f) { 
          return f.getDeclaringClass().equals(RecommendedTab.class); 
         } 

         @Override 
         public boolean shouldSkipClass(Class<?> clazz) { 
          return false; 
         } 
        }) 
        .create(); 
      retrofit = new Retrofit.Builder() 
        .baseUrl(base_url) 
        .addConverterFactory(GsonConverterFactory.create(gson)) 
        .build(); 
     } 

     try 
     { 
      EventsApi eventsApiService = retrofit.create(EventsApi.class); 
      Call<List<EventsData>> call = eventsApiService.getEvents(value1, value2, value3, value4, value5, value6); 
      call.enqueue(new Callback<List<EventsData>>() { 
       @Override 
       public void onResponse(Call<List<EventsData>> call, Response<List<EventsData>> response) { 
        List<EventsData> movies = response.body(); 
        recyclerView.setAdapter(new EventsAdapter(movies, getContext())); 
        System.out.println("Number of movies received: " + movies.size()); 
       } 

       @Override 
       public void onFailure(Call<List<EventsData>> call, Throwable t) { 

       } 
      }); 

EventsApi.interface

public interface EventsApi { 
    @GET("venues/search") 
    Call<List<EventsData>> getEvents(
      @Query("a") String value1, 
      @Query("b") String value2, 
      @Query("c") String value3, 
      @Query("d") String value4, 
      @Query("e") String value5, 
      @Query("f") String value6 
    ); 
} 

EventsData.java

public class EventsData 
{ 
    private List<EventsData> results; 

    public EventsData() 
    { } 

    public List<EventsData> getResults() { 
     return results; 
    } 
    public void setResults(List<EventsData> results) { 
     this.results = results; 
    } 
} 

答えて

0

あなたEventsDataクラスのみList<EventsData>が含まれています、再帰的地獄のレシピのようだ。これはバグでしょうか?

関連する問題