2017-11-01 50 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>을 포함, 그것은 재귀 지옥의 제조법처럼 보입니다. 아마도 이것은 버그입니까?